SQL loader syntax question

SQL * Loader: release 11.1.0.7.0 - Production on Wed Mar 18 07:21:37 2010

Copyright (c) 1982, 2007, Oracle. All rights reserved.

SQL * Loader-350: at line 1 syntax error.
Expecting keyword SUPPORT, found "DI".
DIA¡±a
^

My sqlldr file looks like this:

sqlldr control=C:\data\ctl\ss.ctl log=C:\data\logs\ss.log userid = user/password errors = 999 discard=C:\data\discard\ss.dis

control file looks like this:

DOWNLOAD THE DATA
INFILE ' C:\data\SS. TXT' "STR"\r\n"
REPLACE
IN THE SS TABLE
FIELDS TERMINATED BY '; '.
TRAILING NULLCOLS
(
ACCOUNT_NBR TANK,
ADDR1 TANK,
ADDR2 TANK,
ADDR3 TANK,
ADDR4 CHAR,
TANK OF THE CITY,
STATE TANK,
POSTCODE TANK,

.......
more columns are all the same syntax and char column name
)

I can load this table using enterprise manager but when you use the sqlldr his does not work.
Something stand out?

Published by: mlojan on March 18, 2010 05:33

The only thing I can think is some characters problem between the file of control and operating system/oracle server.

You have the control file using a text editor such as Notepad or wordpad haven't you? You have not used something like MS Word?

Tags: Database

Similar Questions

  • SQL * Loader syntax

    DOWNLOAD THE DATA
    INFILE 'c:\folder\sample.txt '.
    DISCARDFILE 'c:\folder\sample.dis '.
    ADD IN THE TABLE user.tmp_tbl
    FIELDS TERMINATED BY ' ~'
    WHEN (1) = "1"
    (record_type,
    Key_ID,
    Key3,
    Key4
    )
    Add THE tmp_tbl2 TABLE
    FIELDS TERMINATED BY ' ~'
    WHEN (1) = "2"
    (rec_type,
    Key_ID,
    Key3,
    Key4,
    region_cd
    )

    Get the following error
    SQL * LOADER - 350:SYNTAX IN LINE 6.
    WAITING FOR "(" FIND KEYWORD WHEN
    WHEN (1) = "1"
    ^

    It looks good to me, but it might be the location of your clause 'fields terminated by '.

    See examples here:

    http://www.orafaq.com/Forum/t/63674/0/

    DOWNLOAD THE DATA
    ADD
    IN THE LOGO OF THE TABLE
    WHEN (01) = '1'
    FIELDS TERMINATED BY ' |'
    EVENTUALLY FRAMED BY ' '
    TRAILING NULLCOLS
    (
    INDICATOR FILLING position (1).
    LOGO_CD,
    LOGO_NM,
    LOGO_DESC_TX "decode(:LOGO_DESC_TX,,:LOGO_NM,:LOGO_NM)"
    LOGO_EFF_DT 'trunc (sysdate). "
    LOGO_TRMNT_DT FILLING,
    CRE_USR_ID "USER."
    CRE_TS SYSDATE,
    UPDT_USR_ID "USER."
    UPDT_TS SYSDATE
    )
    IN THE LTR_LOGO TABLE
    WHEN (01) = '2'
    FIELDS TERMINATED BY ' |'
    EVENTUALLY FRAMED BY ' '
    TRAILING NULLCOLS
    (
    FILLING of INDICATOR1 position (1).
    ACCT_ORG_CD "TO_NUMBER(:ACCT_ORG_CD)"
    LOGO_CD,
    LTR_LOGO_EFF_DT 'trunc (sysdate). "
    LTR_LOGO_TRMNT_DT FILLING,
    CRE_USR_ID "USER."
    CRE_TS SYSDATE,
    UPDT_USR_ID "USER."
    UPDT_TS SYSDATE
    )

  • SQL loader question

    Hi people,

    Please find the table with the records below

    CREATE TABLE EMPLOYEE_LOAD (ID NUMBER, NAME VARCHAR2 (100), UNIVERSITY_NAME VARCHAR2 (100));

    File to load: employee.txt

    ID | NAME | UNIVERSITY_NAME

    1. JAMES | UNIVERSITY OF MIT

    2. LISA | UNIVERSITY OF CAMBRIDGE

    3. MINDY | "THIS UNIVERSITY

    4. ' ALLEN J |' IT UNIVERSITY

    5. ' MIKE'ALLEN | "THIS UNIVERSITY

    I've written SQL Loader control as file below

    OPTIONS(SKIP=1,DIRECT=TRUE)

    DOWNLOAD THE DATA

    INFILE ' mnt/employee.txt.

    BADFILE "mnt/employee.bad.

    DISCARDFILE ' mnt/employee.dsc.

    ADD THE EMPLOYEE_LOAD TABLE

    FIELDS TERMINATED BY ' | '. SURROUNDED OF POSSIBLY ' ' ' TRAILING NULLCOLS

    (

    ID,

    NAME,

    UNIVERSITY_NAME

    )

    sqlldr userid = < username > @database/password control=/mnt/employee.ctl log=/mnt/employee.log

    Only 2 first recordings are loading (excluding the header) and face below errors

    (1) no terminator found after CLOSE and CLOSED field

    (2) second string for the attachment does not exist

    These 3 recordings are in the wrong files and how do I force sql loader to load subfolders too?

    3. MINDY | "THIS UNIVERSITY

    4. ' ALLEN J |' IT UNIVERSITY

    5. ' MIKE'ALLEN | "THIS UNIVERSITY

    Try to remove the ENCLOSED BY ' ' ' clause.  It is not true, according to your sample data.

    These quotes seem to be interspersed randomly.

  • Question to load data using sql loader in staging table, and then in the main tables!

    Hello

    I'm trying to load data into our main database table using SQL LOADER. data will be provided in separate pipes csv files.

    I have develop a shell script to load the data and it works fine except one thing.

    Here are the details of a data to re-create the problem.

    Staging of the structure of the table in which data will be filled using sql loader

    create table stg_cmts_data (cmts_token varchar2 (30), CMTS_IP varchar2 (20));

    create table stg_link_data (dhcp_token varchar2 (30), cmts_to_add varchar2 (200));

    create table stg_dhcp_data (dhcp_token varchar2 (30), DHCP_IP varchar2 (20));

    DATA in the csv file-

    for stg_cmts_data-

    cmts_map_03092015_1.csv

    WNLB-CMTS-01-1. 10.15.0.1

    WNLB-CMTS-02-2 | 10.15.16.1

    WNLB-CMTS-03-3. 10.15.48.1

    WNLB-CMTS-04-4. 10.15.80.1

    WNLB-CMTS-05-5. 10.15.96.1

    for stg_dhcp_data-

    dhcp_map_03092015_1.csv

    DHCP-1-1-1. 10.25.23.10, 25.26.14.01

    DHCP-1-1-2. 56.25.111.25, 100.25.2.01

    DHCP-1-1-3. 25.255.3.01, 89.20.147.258

    DHCP-1-1-4. 10.25.26.36, 200.32.58.69

    DHCP-1-1-5 | 80.25.47.369, 60.258.14.10

    for stg_link_data

    cmts_dhcp_link_map_0309151623_1.csv

    DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2

    DHCP-1-1-2. WNLB-CMTS-03-3,WNLB-CMTS-04-4,WNLB-CMTS-05-5

    DHCP-1-1-3. WNLB-CMTS-01-1

    DHCP-1-1-4. WNLB-CMTS-05-8,WNLB-CMTS-05-6,WNLB-CMTS-05-0,WNLB-CMTS-03-3

    DHCP-1-1-5 | WNLB-CMTS-02-2,WNLB-CMTS-04-4,WNLB-CMTS-05-7

    WNLB-DHCP-1-13 | WNLB-CMTS-02-2

    Now, after loading these data in the staging of table I have to fill the main database table

    create table subntwk (subntwk_nm varchar2 (20), subntwk_ip varchar2 (30));

    create table link (link_nm varchar2 (50));

    SQL scripts that I created to load data is like.

    coil load_cmts.log

    Set serveroutput on

    DECLARE

    CURSOR c_stg_cmts IS SELECT *.

    OF stg_cmts_data;

    TYPE t_stg_cmts IS TABLE OF stg_cmts_data % ROWTYPE INDEX BY pls_integer;

    l_stg_cmts t_stg_cmts;

    l_cmts_cnt NUMBER;

    l_cnt NUMBER;

    NUMBER of l_cnt_1;

    BEGIN

    OPEN c_stg_cmts.

    Get the c_stg_cmts COLLECT in BULK IN l_stg_cmts;

    BECAUSE me IN l_stg_cmts. FIRST... l_stg_cmts. LAST

    LOOP

    SELECT COUNT (1)

    IN l_cmts_cnt

    OF subntwk

    WHERE subntwk_nm = l_stg_cmts (i) .cmts_token;

    IF l_cmts_cnt < 1 THEN

    INSERT

    IN SUBNTWK

    (

    subntwk_nm

    )

    VALUES

    (

    l_stg_cmts (i) .cmts_token

    );

    DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_cmts (i) .cmts_token);

    ON THE OTHER

    DBMS_OUTPUT. Put_line ("token is already present'");

    END IF;

    WHEN l_stg_cmts EXIT. COUNT = 0;

    END LOOP;

    commit;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    for dhcp


    coil load_dhcp.log

    Set serveroutput on

    DECLARE

    CURSOR c_stg_dhcp IS SELECT *.

    OF stg_dhcp_data;

    TYPE t_stg_dhcp IS TABLE OF stg_dhcp_data % ROWTYPE INDEX BY pls_integer;

    l_stg_dhcp t_stg_dhcp;

    l_dhcp_cnt NUMBER;

    l_cnt NUMBER;

    NUMBER of l_cnt_1;

    BEGIN

    OPEN c_stg_dhcp.

    Get the c_stg_dhcp COLLECT in BULK IN l_stg_dhcp;

    BECAUSE me IN l_stg_dhcp. FIRST... l_stg_dhcp. LAST

    LOOP

    SELECT COUNT (1)

    IN l_dhcp_cnt

    OF subntwk

    WHERE subntwk_nm = l_stg_dhcp (i) .dhcp_token;

    IF l_dhcp_cnt < 1 THEN

    INSERT

    IN SUBNTWK

    (

    subntwk_nm

    )

    VALUES

    (

    l_stg_dhcp (i) .dhcp_token

    );

    DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_dhcp (i) .dhcp_token);

    ON THE OTHER

    DBMS_OUTPUT. Put_line ("token is already present'");

    END IF;

    WHEN l_stg_dhcp EXIT. COUNT = 0;

    END LOOP;

    commit;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    for link -.

    coil load_link.log

    Set serveroutput on

    DECLARE

    l_cmts_1 VARCHAR2 (4000 CHAR);

    l_cmts_add VARCHAR2 (200 CHAR);

    l_dhcp_cnt NUMBER;

    l_cmts_cnt NUMBER;

    l_link_cnt NUMBER;

    l_add_link_nm VARCHAR2 (200 CHAR);

    BEGIN

    FOR (IN) r

    SELECT dhcp_token, cmts_to_add | ',' cmts_add

    OF stg_link_data

    )

    LOOP

    l_cmts_1: = r.cmts_add;

    l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));

    SELECT COUNT (1)

    IN l_dhcp_cnt

    OF subntwk

    WHERE subntwk_nm = r.dhcp_token;

    IF l_dhcp_cnt = 0 THEN

    DBMS_OUTPUT. Put_line ("device not found: ' |") r.dhcp_token);

    ON THE OTHER

    While l_cmts_add IS NOT NULL

    LOOP

    l_add_link_nm: = r.dhcp_token |' _TO_' | l_cmts_add;

    SELECT COUNT (1)

    IN l_cmts_cnt

    OF subntwk

    WHERE subntwk_nm = TRIM (l_cmts_add);

    SELECT COUNT (1)

    IN l_link_cnt

    LINK

    WHERE link_nm = l_add_link_nm;

    IF l_cmts_cnt > 0 AND l_link_cnt = 0 THEN

    INSERT INTO link (link_nm)

    VALUES (l_add_link_nm);

    DBMS_OUTPUT. Put_line (l_add_link_nm |) » '||' Has been added. ") ;

    ELSIF l_link_cnt > 0 THEN

    DBMS_OUTPUT. Put_line (' link is already present: ' | l_add_link_nm);

    ELSIF l_cmts_cnt = 0 then

    DBMS_OUTPUT. Put_line (' no. CMTS FOUND for device to create the link: ' | l_cmts_add);

    END IF;

    l_cmts_1: = TRIM (SUBSTR (l_cmts_1, INSTR (l_cmts_1, ',') + 1));

    l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));

    END LOOP;

    END IF;

    END LOOP;

    COMMIT;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    control files -

    DOWNLOAD THE DATA

    INFILE 'cmts_data.csv '.

    ADD

    IN THE STG_CMTS_DATA TABLE

    When (cmts_token! = ") AND (cmts_token! = 'NULL') AND (cmts_token! = 'null')

    and (cmts_ip! = ") AND (cmts_ip! = 'NULL') AND (cmts_ip! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:cmts_token))' cmts_token,

    cmts_ip ' RTRIM (LTRIM(:cmts_ip)) ")". "

    for dhcp.


    DOWNLOAD THE DATA

    INFILE 'dhcp_data.csv '.

    ADD

    IN THE STG_DHCP_DATA TABLE

    When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')

    and (dhcp_ip! = ") AND (dhcp_ip! = 'NULL') AND (dhcp_ip! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:dhcp_token))' dhcp_token,

    dhcp_ip ' RTRIM (LTRIM(:dhcp_ip)) ")". "

    for link -.

    DOWNLOAD THE DATA

    INFILE 'link_data.csv '.

    ADD

    IN THE STG_LINK_DATA TABLE

    When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')

    and (cmts_to_add! = ") AND (cmts_to_add! = 'NULL') AND (cmts_to_add! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:dhcp_token))' dhcp_token,

    cmts_to_add TANK (4000) RTRIM (LTRIM(:cmts_to_add)) ")" ""

    SHELL SCRIPT-

    If [!-d / log]

    then

    Mkdir log

    FI

    If [!-d / finished]

    then

    mkdir makes

    FI

    If [!-d / bad]

    then

    bad mkdir

    FI

    nohup time sqlldr username/password@SID CONTROL = load_cmts_data.ctl LOG = log/ldr_cmts_data.log = log/ldr_cmts_data.bad DISCARD log/ldr_cmts_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    nohup time username/password@SID @load_cmts.sql

    nohup time sqlldr username/password@SID CONTROL = load_dhcp_data.ctl LOG = log/ldr_dhcp_data.log = log/ldr_dhcp_data.bad DISCARD log/ldr_dhcp_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    time nohup sqlplus username/password@SID @load_dhcp.sql

    nohup time sqlldr username/password@SID CONTROL = load_link_data.ctl LOG = log/ldr_link_data.log = log/ldr_link_data.bad DISCARD log/ldr_link_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    time nohup sqlplus username/password@SID @load_link.sql

    MV *.log. / log

    If the problem I encounter is here for loading data in the link table that I check if DHCP is present in the subntwk table, then continue to another mistake of the newspaper. If CMTS then left create link to another error in the newspaper.

    Now that we can here multiple CMTS are associated with unique DHCP.

    So here in the table links to create the link, but for the last iteration of the loop, where I get separated by commas separate CMTS table stg_link_data it gives me log as not found CMTS.

    for example

    DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2

    Here, I guess to link the dhcp-1-1-1 with balancing-CMTS-01-1 and wnlb-CMTS-02-2

    Theses all the data present in the subntwk table, but still it gives me journal wnlb-CMTS-02-2 could not be FOUND, but we have already loaded into the subntwk table.

    same thing is happening with all the CMTS table stg_link_data who are in the last (I think here you got what I'm trying to explain).

    But when I run the SQL scripts in the SQL Developer separately then it inserts all valid links in the table of links.

    Here, she should create 9 lines in the table of links, whereas now he creates only 5 rows.

    I use COMMIT in my script also but it only does not help me.

    Run these scripts in your machine let me know if you also get the same behavior I get.

    and please give me a solution I tried many thing from yesterday, but it's always the same.

    It is the table of link log

    link is already present: dhcp-1-1-1_TO_wnlb-cmts-01-1

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-02-2

    link is already present: dhcp-1-1-2_TO_wnlb-cmts-03-3
    link is already present: dhcp-1-1-2_TO_wnlb-cmts-04-4

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-5

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-01-1

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-8
    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-6
    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-0

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-03-3

    link is already present: dhcp-1-1-5_TO_wnlb-cmts-02-2
    link is already present: dhcp-1-1-5_TO_wnlb-cmts-04-4

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-7

    Device not found: wnlb-dhcp-1-13

    IF NEED MORE INFORMATION PLEASE LET ME KNOW

    Thank you

    I felt later in the night that during the loading in the staging table using UNIX machine he created the new line for each line. That is why the last CMTS is not found, for this I use the UNIX 2 BACK conversion and it starts to work perfectly.

    It was the dos2unix error!

    Thank you all for your interest and I may learn new things, as I have almost 10 months of experience in (PLSQL, SQL)

  • SQL LOADER LPAD CONTROL FILE IN QUESTION

    Hi, in the flat file
    company_cd is "1" or "01".
    and center_cd is 3 digits... ex: "493".

    in the table, the column username must be 6 digits

    Currently, I get this as a username in the table

    "010493" is right, for company_cd is '01 '.
    '10493' isn't fair, because company_cd is '1 '.

    If company_cd is 2 digits (01) I receive 6 digit userid which is OK
    but when company_cd is singile digit (1) I get 5-digit userid

    I have NEED OF LPAD with 0 in the front when company_cd is '1' any suggetions?



    This is the code that I use currently in the CTL file for userid *.

    , Username "CONCAT (substr (trim (:company_cd),1,2),lpad(trim(:center_cd),4,0)).


    ....... Thank you...

    Published by: phani_Marella on August 28, 2012 11:12

    Now company "coz" origin all of a sudden?
    I don't know read you {message identifier: = 9360002}, hence my confusion.
    Anyway, the SQL * Loader forum is @ export/import/SQL Loader & external Tables

  • Syntax SQL LOADER

    Hi guru. !!!

    can someone tell me abt advantage of charger sq in 11g on sql loader in 10g... !!!

    Please help me with this... !!!

    user13490153 wrote:
    Hi guru. !!!

    can someone tell me abt advantage of charger sq in 11g on sql loader in 10g... !!!

    Please help me with this... !!!

    not sure, there is really no version 11 g and 10g n/b difference!

    Better would be to use external tables.

    http://www.morganslibrary.org/reference/externaltab.html

    ... and keep all your processing in the database rather than from the command line.

  • Error loading data using SQL loader

    I get an error message like "SQL * Loader - 350 combination illegal syntax of non-alphanumeriques characters error during loading of a file using SQL loader in RHEL." The command used to run SQL * Loader is:

    Sqlldr userid = < user name > / < password > control = data.ctl

    The control file is data.ctl:

    DOWNLOAD the data

    INFILE ' / home/oraprod/data.txt'

    Add in the table test

    {

    EmpID completed by «,»,

    fname completed by «,»,

    lname completed by «,»,

    treatment is completed with a white space

    }

    The data.txt file is:

    1, Kaushal, Hamad, 5000

    2, Chetan, Hamad, 1000

    Hopefully, my question is clear.

    Please get back with the answer to my query.

    Concerning

    Replace "{" by "("dans votre fichier de contrôle) "

    DOWNLOAD the data

    INFILE 'c:\data.txt.

    Add the emp_t table

    (

    EmpID completed by «,»,

    fname completed by «,»,

    lname completed by «,»,

    treatment is completed with a white space

    )

    C:\>sqlldr user/pwd@database control = c.ctl

    SQL * Loader: release 10.2.0.3.0 - Production on Wed Nov 13 10:10:24 2013

    Copyright (c) 1982, 2005, Oracle.  All rights reserved.

    Commit the point reached - the number of logical records 1

    Commit the point reached - the number of logical records 2

    SQL > select * from emp_t;

    EMPID, FNAME LNAME SALARY

    ---------- -------------------- -------------------- ----------

    1 kone hamadi 5000

    2 Chetan Hamad 1000

    Best regards

    Mohamed Houri

  • SQL Loader - null is not recognized

    Hi, I have a very strange question that I would really appreciate help with.

    We have the file following sql ctl charger that works very well.

    OPTIONS (DIRECT = TRUE, PARALLEL = FALSE, ERRORS = 0, BINDSIZE = 50000, LINES = 10000, READ)

    SIZE = 65536)

    DOWNLOAD THE DATA

    CHARACTERSET WE8MSWIN1252

    INFILE 'file1' "STR X ' 0 and has.

    READBUFFERS 4

    IN THE TABLE test.tabl1

    TRUNCATE

    REACTIVATE THE DISABLED_CONSTRAINTS

    FIELDS

    (

    POSITION TANK (01:25) "DT_TM_ADDED" "DECODE (SUBSTR (: DT_TM_ADDED, 13.2), null,).

    Substr(:dt_tm_added,1,11) | "(00:00:00 ',: DT_TM_ADDED) ' etc. .

    We must now change our ctl files so the fields are completed by |

    It now looks like this.

    FIELDS TERMINATED BY ' |'

    (

    "DT_TM_ADDED" TANK "DECODE (SUBSTR (: DT_TM_ADDED, 13.2), null, substr(:dt_tm_add)).

    Ed, 1, 11). 00:00:00',TRIM(:DT_TM_ADDED)) ", etc.

    This works great besides when the DT_TM_ADDED, 13.2 has a value zero. Its not picking up that it is worth zero. If I change the statement as follows using a ' ' instead of null, IE (: DT_TM_ADDED, 13.2), ' ', substr,... it works very well.


    Am I missing something really obvious here?

    Any help would be really appreciated.

    Morgan Library has great demos on SQL LOADER.

    Demo 6

    "Use keywords NULLIF and DRAFTS to manage a length no strings loaded into numeric columns. Also note the use of the Direct path load in the control file (DIRECT = TRUE). »

    Link: Oracle 12 c SQL * Loader

    It could be that useful...

  • SQL * Loader: TRUNCATE TO ADD one IN the other

    Is it possible to TRONQUER IN 5 tables and ADD IN 1, in the same control file?

    APPEND it would be the data from the footer, add to this batch file. The data TABLEs are truncated between charges.

    Yes, the syntax is slightly different.  Instead of putting TRUNCATE or APPEND at the top of the control file, you have TRUNCATE or APPEND after each table name in the INTO TABLE clause before the WHEN clause.  Please see the example below who truncates table ab and inserts into the cd table.

    Scott@orcl12c > host type test.dat

    AB, 123, efg

    CD, hij, 456

    Scott@orcl12c > type host test.ctl

    load data

    in the ab table TRUNCATE when (1:2) = "ab".

    fields ended by ',' trailing nullcols

    (table_name filler position (1), col1, col2)

    in the cd table ADD when (1:2) = "cd".

    fields ended by ',' trailing nullcols

    (table_name filler position (1), col3, col4)

    Scott@orcl12c > create table ab

    2 (col1 number,

    3 col2 varchar2 (8))

    4.

    Table created.

    Scott@orcl12c > insert into ab values (1, 'old data')

    2.

    1 line of creation.

    Scott@orcl12c > create table cd

    2 (col3 varchar2 (8))

    3 col4 number)

    4.

    Table created.

    Scott@orcl12c > insert into cd values ("old data", 1).

    2.

    1 line of creation.

    Scott@orcl12c > commit

    2.

    Validation complete.

    Scott@orcl12c > host sqlldr scott/tiger control = test.ctl data = test.dat log = test.log

    SQL * Loader: release 12.1.0.1.0 - Production on Tue Mar 25 13:20:29 2014

    Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.

    Path used: classics

    Commit the point reached - the number of logical records 2

    Table AB:

    1 row loaded successfully.

    Table D:

    1 row loaded successfully.

    Check the log file:

    test.log

    For more information on the charge.

    Scott@orcl12c > select * AB

    2.

    COL1 COL2

    ---------- --------

    EFG 123

    1 selected line.

    Scott@orcl12c > select * from cd

    2.

    COL3 COL4

    -------- ----------

    old data 1

    hij 456

    2 selected lines.

  • SQL loader - control files

    Hi all

    I have a file with data. I want to insert only the exp_data < = current data in the control file. My like this.

    DOWNLOAD THE DATA

    INFILE ' D:\sample. DAT'

    TRUNCATE

    IN THE TABLE s_TABLE WHEN (1:6) < = "(to_char(sysdate,'mmddyy')).

    TRAILING NULLCOLS

    (

    eff_data position(1:6).

    name position(7:20)

    )

    During the execution of this I got error like this

    SQL * Loader-350: at line 48 syntax error.
    Illegal combination of nonalphanumeric characters
    IN THE TABLE s_TABLE WHEN (1:6) < = "(to_char (sysdate, e

    If I use with less symbol I receives the data. Is another way to achieve this scenario. If you need more data I'll provide you with.

    Thank you.

    Hello

    Some examples of data.

    011413DBTEST

    011513DBDATAFORTEST

    102313DATA

    Table as:

    Create the table s_TABLE

    (

    eff_data varchar2 (6).

    name varchar2 (20)

    )

  • SQL Loader - Skip empty, blank &amp; space lines

    Hi all

    I load data into MS-Excel using SQL Loader.

    Question:

    If all the blank lines or spaces lines are there, currently it's inclusion as an empty entry.

    Control file

    OPTIONS (SKIP = 1)

    load data

    in the temp_upload table

    Add

    fields ended by ',' optionally surrounded "" "

    TRAILING NULLCOLS

    (

    SPNAME "TRIM(:SPNAME)."

    GROUP OF USERS "TRIM(:USERGROUP)."

    IS_BUSINESS_CRITICAL "TRIM(:IS_BUSINESS_CRITICAL)"

    BUSINESS_CRITICAL_COMMENT "TRIM(:BUSINESS_CRITICAL_COMMENT)"

    BATCH_ID "(select batch_id de batch_tab) expression", "

    ID 'TEMP_UPLOAD_ID_SEQ. NEXTVAL '.

    )

    Help:


    Any solution to this problem? Please help me solve this problem.

    Ordinarily, SQL * Loader will reject, by default, all the rows where all columns are null.  However, when you assign the batch_id and id, these columns are null, the line is busy.  You can use SQL * Loader or external table to load the data into a staging table without these id, which will skip null lines, then insert into your target, adding the id, as shown below.

    Scott@orcl_11gR2 > host type test.dat

    Some title or column names

    spname1 usergroup1 ibc1, bcc1, batch1,

    spname3, usergroup3, ibc3, bcc3, batch3,

    Scott@orcl_11gR2 > type host test.ctl

    OPTIONS (SKIP = 1)

    load data

    in the staging table

    Add

    fields ended by ',' optionally surrounded "" "

    TRAILING NULLCOLS

    (

    SPNAME 'TRIM(:SPNAME) '.

    , GROUP OF USERS "TRIM(:USERGROUP)."

    , IS_BUSINESS_CRITICAL 'TRIM(:IS_BUSINESS_CRITICAL) '.

    , BUSINESS_CRITICAL_COMMENT 'TRIM(:BUSINESS_CRITICAL_COMMENT) '.

    )

    Scott@orcl_11gR2 > creating staging table

    2 (SPNAME varchar2 (7))

    3 usergroup varchar2 (10),

    4 IS_BUSINESS_CRITICAL varchar2 (4).

    5 BUSINESS_CRITICAL_COMMENT varchar2 (4))

    6.

    Table created.

    Scott@orcl_11gR2 > host sqlldr scott/tiger control = test.ctl data = test.dat log = test.log

    SQL * Loader: release 11.2.0.1.0 - Production Wed Jul 3 11:08:04 2013

    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

    Commit the point reached - the number of logical records 3

    Scott@orcl_11gR2 > select * from staging

    2.

    SPNAME USERGROUP IS_B BUSI

    ------- ---------- ---- ----

    spname1 usergroup1 ibc1 bcc1

    spname3 usergroup3 ibc3 bcc3

    2 selected lines.

    Scott@orcl_11gR2 > create table temp_upload

    2 (SPNAME varchar2 (7))

    3 usergroup varchar2 (10),

    4 IS_BUSINESS_CRITICAL varchar2 (4).

    5 BUSINESS_CRITICAL_COMMENT varchar2 (4).

    6 number BATCH_ID,

    Number 7)

    8.

    Table created.

    Scott@orcl_11gR2 > create table batch_tab as select 10 double batch_id

    2.

    Table created.

    Scott@orcl_11gR2 > create sequence temp_upload_id_seq

    2.

    Order of creation.

    Scott@orcl_11gR2 > insert into temp_upload

    2. Select usergroup, spname, is_business_critical, business_critical_comment,

    3 (selection batch_id batch_tab),

    4 temp_upload_id_seq.nextval

    5 staging

    6.

    2 rows created.

    Scott@orcl_11gR2 > select * from temp_upload

    2.

    SPNAME USERGROUP IS_B BUSI BATCH_ID ID

    ------- ---------- ---- ---- ---------- ----------

    spname1 usergroup1 ibc1 bcc1 10 1

    spname3 usergroup3 ibc3 10 2 bcc3

    2 selected lines.

  • SQL Loader - does not

    I have Oracle 11 g R2 running on Windows Server 2008 R2

    When trying to load the data (csv file) with SQL Loader in Enterprise Manager, he told me the work successfully completed, but there is no data in the table. The bat is created as the ctl and sh file. I checked that sqldr is in my directory \bin to $ORACLE_HOME$ and I checked that this 'path' is also in my path environment variable. When I try to run it from the command line that I don't get recognized as builtin or external, an executable program or batch file. I try to run it in SQL Developer, and after his execution, it is said canceled task. Can help you. I expect a record 70 million next week and I want to use SQL Loader.

    Message from Enterprise Manager
    State managed
    Exit code 0
    31327 step ID
    Target leads.global
    Started may 10, 2013 15:55:14 (UTC-07:00)
    Ended May 10, 2013 15:55:22 (UTC-07:00)
    Step 8 seconds
    WIN Service Management - D1CINRVM11K:1158_Management_Service
    Including the job step ADVANCED management service was sent.



    Natural logarithm of output


    User name:
    SQL * Loader: release 11.2.0.1.0 - Production Friday, may 10, 15:55:15 2013

    Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.


    Loaded - the number of logical records 51.

    I usually run SQL * Loader of SQL * Plus, so that it avoids some of the questions of privilege. I also use a log file, so that I can check later to see what happened and why. For example:

    host sqlldr scott/tiger control = test.ctl log = test.log

    A common question is the lack of privileges for the data file to load. You can change an empty file in SQL * more and copy and paste the data into it, to eliminate such problems or identify them, so that you can check the privileges on the original file.

    To provide a lot of other things, we would need more information, such as a few lines of sample data, your SQL * Loader control file and the structure of your table.

  • SQL Loader what Condition

    Hello. I am currently using the when option in my SQL Loader script:
    when (01:07) <> '9000001'
    But now I find that I must exclude several channels '9000001', '9000002 ', '9000003', 9000004'. Is there a way to do this? Any help would be greatly appreciated.

    Sharpe says:
    Awesome. Thank you. One last question... If I have these channels (for example '9000001', etc.) stored in a different table is anyway to reject the records corresponding to this value into my table? Something like a nested statement select?

    when (01:07) not in(select mystr from mytable)
    

    Let me know is that references a table is possible or not. Thank you.

    As far as I know, you can do that. I believe that the Organizer must be or = or! = and to compare value must be a literal, not a select function or expression. You can use SQL * Loader (or an external table if your data on the server, not the client) to load the data into a staging table, then use SQL to insert... where... not in (mystr select from myTable).

  • SQL Loader and batch ID

    Hi all

    In our application, we allow the user to download data using the worksheet in the excel user interface.

    We use a PHP script in the user interface and using SQL Loader to load the data of insert_table excel sheet.

    The insert_table has a primary key.


    Here, my question is, is it possible to put some package for each download id in the table in an automatic way?

    While we can easily extract data using the code batch

    We use Oracle 11 g.

    What is load a constant value, in which case you may as well use 815 constant in your control file. If you want to automatically increment the value of each batch, then you must use a different method.

    Please see the example below. Before each data load, he loads the next value in the sequence into a separate table and then selects this value while loading data. Note that SQL * expression of charger that uses select must appear in parentheses in the double quotes.

    SCOTT@orcl_11gR2> host type test1.dat
    1 Prod1
    2 Prod2
    3 Prod3
    4 Prod4
    5 Prod5
    
    SCOTT@orcl_11gR2> host type test2.dat
    6 Prod6
    7 Prod7
    8 Prod8
    
    SCOTT@orcl_11gR2> host type batch.ctl
    options(load=1)
    load data
    replace
    into table batch_tab
    (batch_id expression "test_seq.nextval")
    
    SCOTT@orcl_11gR2> host type data.ctl
    load data
    append
    into table temp_table
    fields terminated by whitespace
    trailing nullcols
    (p_id,
    p_name,
    batch_id expression "(select batch_id from batch_tab)")
    
    SCOTT@orcl_11gR2> create table temp_table
      2    (p_id      number primary key,
      3     p_name    varchar2(6),
      4     batch_id  number)
      5  /
    
    Table created.
    
    SCOTT@orcl_11gR2> create sequence test_seq
      2  /
    
    Sequence created.
    
    SCOTT@orcl_11gR2> create table batch_tab
      2    (batch_id  number)
      3  /
    
    Table created.
    
    SCOTT@orcl_11gR2> -- first load:
    SCOTT@orcl_11gR2> host sqlldr scott/tiger control=batch.ctl log=batch1.log
    
    SQL*Loader: Release 11.2.0.1.0 - Production on Fri Apr 19 17:16:33 2013
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    Commit point reached - logical record count 1
    
    SCOTT@orcl_11gR2> host sqlldr scott/tiger control=data.ctl data=test1.dat log=test1.log
    
    SQL*Loader: Release 11.2.0.1.0 - Production on Fri Apr 19 17:16:33 2013
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    Commit point reached - logical record count 5
    
    SCOTT@orcl_11gR2> select * from batch_tab
      2  /
    
      BATCH_ID
    ----------
             1
    
    1 row selected.
    
    SCOTT@orcl_11gR2> select * from temp_table
      2  /
    
          P_ID P_NAME   BATCH_ID
    ---------- ------ ----------
             1 Prod1           1
             2 Prod2           1
             3 Prod3           1
             4 Prod4           1
             5 Prod5           1
    
    5 rows selected.
    
    SCOTT@orcl_11gR2> -- second load:
    SCOTT@orcl_11gR2> host sqlldr scott/tiger control=batch.ctl log=batch2.log
    
    SQL*Loader: Release 11.2.0.1.0 - Production on Fri Apr 19 17:16:33 2013
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    Commit point reached - logical record count 1
    
    SCOTT@orcl_11gR2> host sqlldr scott/tiger control=data.ctl data=test2.dat log=test2.log
    
    SQL*Loader: Release 11.2.0.1.0 - Production on Fri Apr 19 17:16:33 2013
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    Commit point reached - logical record count 3
    
    SCOTT@orcl_11gR2> select * from batch_tab
      2  /
    
      BATCH_ID
    ----------
             2
    
    1 row selected.
    
    SCOTT@orcl_11gR2> select * from temp_table
      2  /
    
          P_ID P_NAME   BATCH_ID
    ---------- ------ ----------
             1 Prod1           1
             2 Prod2           1
             3 Prod3           1
             4 Prod4           1
             5 Prod5           1
             6 Prod6           2
             7 Prod7           2
             8 Prod8           2
    
    8 rows selected.
    
  • SQL Loader Help in 10g

    Hello

    Is it possible to abort the sql loader with force when a value is not present? I have data like this file

    1. XXX123 | XXX | 20121121 |
    4. XXX123 | XXX |
    5. XXX123 | XXX | 1.
    5. XXX123 | XXX | 2.
    5. XXX123 | XXX |
    9. XXX123 | XXX |

    Model:
    record type | Batch number. lot desc | date | detail line num | other

    1,4,5,9 are the types of records, if you see this line 5. XXX123 | XXX | 1| .. 1 represents a number of detail line, my requirement is if the number of detail line is null for the record type 5 then I want to abort the sqlloader.

    Is this possible?

    Published by: 940838 on November 21, 2012 23:54

    940838 wrote:
    I think that I am not clear in my requirement...

    The question was how to abort the charger if the number of detail line is not present in the record type 5. It is, however, normal detailing line num is not required for other types of records. points of view.

    Hello

    you were clear, and I did a quick test. Unfortunately you can not do this check in SQL * Loader as the WHEN in the control file clause allows not just GOLD.

    Even if you add this check using a constraint in your table and specify the maximum number of errors to 0, SQL * Loader will load the files until this error.

    Let me show you an example:

    (1) create a table with a constraint that, for record_type detail_line_number 5, may not be null.

    CREATE TABLE test
    (
       record_type    INTEGER
     , batch_number   VARCHAR2 (10)
     , batch_desc     VARCHAR2 (10)
     , batch_date     DATE
     , detail_line_num INTEGER
     , other          VARCHAR2 (10)
    );
    
    ALTER TABLE test
      ADD CONSTRAINT check_rec_5
         CHECK (   record_type = 5 AND detail_line_num IS NOT NULL
                OR record_type != 5) ENABLE;
                
    

    In this table, you will not be able to load lines with a record_type = 5 and NULL detail_line_num as this will be considered an error.

    We will prepare your input file:

    1|XXX123|XXX|20121121||
    4|XXX123|XXX|||
    5|XXX123|XXX||1|
    5|XXX123|XXX|||
    5|XXX123|XXX|||
    9|XXX123|XXX|||
    1|XXX123|XXX|20121121||
    4|XXX123|XXX|||
    5|XXX123|XXX||1|
    5|XXX123|XXX||2|
    5|XXX123|XXX|||
    9|XXX123|XXX|||1|XXX123|XXX|20121121||
    4|XXX123|XXX|||
    5|XXX123|XXX||1|
    5|XXX123|XXX||2|
    5|XXX123|XXX|||
    9|XXX123|XXX|||1|XXX123|XXX|20121121||
    4|XXX123|XXX|||
    5|XXX123|XXX||1|
    5|XXX123|XXX||2|
    

    As you can see that the input file has the fourth line with record_type = 5 and detail_line_num NULL. It is a mistake of the constraint.

    Here I used the control file:

    --test.ctl
    load data
    INFILE 'test.dat'
    APPEND
    INTO TABLE test
    FIELDS TERMINATED BY '|'
    TRAILING NULLCOLS
    (
     record_type     ,
     batch_number    ,
     batch_desc      ,
     batch_date      Date 'YYYYMMDD',
     detail_line_num ,
     other
    )
    

    If I try to run the SQL * Loader and ask to stop at the first error in this way:

    sqlldr userid=yourname/yourpass@yourdb control=test.ctl errors=0 rows=100
    

    SQL * Loader performs only 3 folders because it encounters an error in line 4 and having specified errors = 0 will not continue to load. In fact, the process will continue until she reached the point of validation (in this case 100 lines), but it is not loading any record after the error, or continue to read the file.

    So, if I check the table

    SELECT * FROM test;
    
    RECORD_TYPE BATCH_NUMBER BATCH_DESC BATCH_DATE            DETAIL_LINE_NUM OTHER
    ----------- ------------ ---------- --------------------- --------------- ----------
              1 XXX123       XXX        21-11-2012 00:00:00
              4 XXX123       XXX
              5 XXX123       XXX                                            1           
    

    You will only see the records until you have reached the error.

    This can be avoided, as documented in SQL * Loader manual reference:

    Load interrupted because they exceeded the maximum number of errors


    If the maximum number of errors is exceeded, SQL * Loader stops loading documents in any table and the work accomplished so far is committed.

    As you can see SQL * Loader to interrupt the treatment, but it engage in any case files until this error.

    Another solution is to create an external table in Oracle and do all the checks you want before you copy your table in a database table, as suggested BluShadow.

    Kind regards.
    Al

Maybe you are looking for