SQL Loader inserting string

Hi,
I have recently started using SQL loader and have got a request which i need help in order to do :-
Lets say there is an excel file with data to be loaded into 'test' table. the data looks like this
customer_id   customer_location
+1 new york+
+2 new jersey+
+3 california+
My table Test looks like :-
create table test(customer_id number, customer_name varchar2(4000),customer_location varchar2(200));
now my requirement is that i need to write a control file which populates customer_name field with text 'test_user' for every row in data file.
So the final data should look like this :-
select * from test;
customer_id   customer_name   customer_location
+1 test_user new york+
+2 test_user new jersey+
+3 test_user california+
i am using direct load. Please help me in making control file. i just want to know the logic for populating columns that are not present in excel file.
Thanks in advance.
Edited by: 974647 on Apr 1, 2013 10:17 AM

SQL*Loader supports constants. Read Setting a Column to a Constant Value
SY.

Similar Messages

  • SQL Loader Inserts chr(13) and chr(10) in the first column of every row.

    Hi,
    I have exported a data in a pipe delimited file using TOAD in one database. Now I want to load the data in my local database using SQL Loader. However every time I try to load the data a double quote followed by a new line is entered for the first column of each row. Unfortunately the delimited file is very big and hence can't be posted here. However I tried the same with a customized table and its data and found the same problem. Below are the table structures and control file that I used.
    create table test_sql
    a varchar2(30),
    b date
    insert into test_sql values('51146263',sysdate-3);
    insert into test_sql values('51146261,sysdate-1);
    EXPORTED PIPE DELIMITED FILE_
    A|B|!##!
    51146261|04/14/13 4:55:18 PM|!##!
    51146263|04/12/13 4:55:32 PM|!##!
    create table test_sql1 as select * from test_sql where 1=2;
    CONTROL FILE_
    OPTIONS(SKIP=1)
    LOAD DATA
    INFILE 'C:\Users\Prithwish\Desktop\Test.txt' "str '!##!'"
    PRESERVE BLANKS
    INTO TABLE TEST_SQL1
    FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    A CHAR(2000),
    B DATE "MM/DD/YYYY HH12:MI:SS AM"
    select * from TEST_SQL1;
    After this when I paste it in notepad I get the following result
    A B
    51146261"     14-APR-0013 16:55:18
    51146263"     12-APR-0013 16:55:32.
    I have no idea how the quotes or the newline appear. Is this a Toad bug? Any help would be greatly appreciated. Really urgent.
    Thanks in advance
    Regards

    Hi Harry,
    I actually thought that the str !##! was causing the problem. Actually my original export has some new lines in some specific columns so I can't keep the new line as my line terminator and hence I kept the !##! as my terminator.
    When I put the same data in a notepad and load it there is no problem at all. For e.g I just typed the following in a notepad and the data loaded just fine.
    A|B|!##!
    51146261|01-01-01 10:10:10 AM|!##!
    51146263|01-01-01 11:11:11 AM|!##!
    Its just when I load the exported file there the problem arises though I have verified the file using UNIX as well using octal dump and found no hidden characters.
    Regards,
    Prithwish

  • SQL Loader Inserting Log File Statistics to a table

    Hello.
    I'm contemplating how to approach gathering the statistics from the SQL Loader log file to insert them into a table. I've approached this from a Korn Shell Script perspective previously, but now that I'm working in a Windows environment and my peers aren't keen about batch files and scripting I thought I'd attempt to use SQL Loader itself to read the log file and insert one or more records into a table that tracks data uploads. Has anyone created a control file that accomplishes this?
    My current environment:
    Windows 2003 Server
    SQL*Loader: Release 10.2.0.1.0
    Thanks,
    Luke

    Hello.
    Learned a little about inserting into multiple tables with delimited records. Here is my current tested control file:
    LOAD DATA
    APPEND
    INTO TABLE upload_log
    WHEN (1:12) = 'SQL*Loader: '
    FIELDS TERMINATED BY WHITESPACE
    TRAILING NULLCOLS
    (  upload_log_id   RECNUM
    , filler_field_0  FILLER
    , filler_field_1  FILLER
    , filler_field_2  FILLER
    , filler_field_3  FILLER
    , filler_field_4  FILLER
    , filler_field_5  FILLER
    , day_of_week
    , month
    , day_of_month
    , time_of_day
    , year
    , log_started_on          "TO_DATE((:month ||' '|| :day_of_month ||' '|| :time_of_day ||' '|| :year), 'Mon DD HH24:MI:SS YYYY')"
    INTO TABLE upload_log
    WHEN (1:11) = 'Data File: '
    FIELDS TERMINATED BY ':'
    (  upload_log_id    RECNUM
    , filler_field_0   FILLER  POSITION(1)
    , input_file_name          "TRIM(:input_file_name)"
    INTO TABLE upload_log
    WHEN (1:6) = 'Table '
    FIELDS TERMINATED BY WHITESPACE
    (  upload_log_id   RECNUM
    , filler_field_0  FILLER  POSITION(1)
    , table_name              "RTRIM(:table_name, ',')"
    INTO TABLE upload_rejects
    WHEN (1:7) = 'Record '
    FIELDS TERMINATED BY ':'
    (  upload_rejects_id  RECNUM
    , record_number      POSITION(1)  "TO_NUMBER(SUBSTR(:record_number,8,20))"
    , reason
    INTO TABLE upload_rejects
    WHEN (1:4) = 'ORA-'
    FIELDS TERMINATED BY ':'
    (  upload_rejects_id  RECNUM
    , error_code         POSITION(1)
    , error_desc
    INTO TABLE upload_log
    WHEN (1:22) = 'Total logical records '
    FIELDS TERMINATED BY WHITESPACE
    (  upload_log_id      RECNUM
    , filler_field_0     FILLER  POSITION(1)
    , filler_field_1     FILLER
    , filler_field_2     FILLER
    , action                     "RTRIM(:action, ':')"
    , number_of_records
    INTO TABLE upload_log
    WHEN (1:13) = 'Run began on '
    FIELDS TERMINATED BY WHITESPACE
    TRAILING NULLCOLS
    (  upload_log_id   RECNUM
    , filler_field_0  FILLER  POSITION(1)
    , filler_field_1  FILLER
    , filler_field_2  FILLER
    , day_of_week
    , month
    , day_of_month
    , time_of_day
    , year
    , run_began_on            "TO_DATE((:month ||' '|| :day_of_month ||' '|| :time_of_day ||' '|| :year), 'Mon DD HH24:MI:SS YYYY')"
    INTO TABLE upload_log
    WHEN (1:13) = 'Run ended on '
    FIELDS TERMINATED BY WHITESPACE
    TRAILING NULLCOLS
    (  upload_log_id   RECNUM
    , filler_field_0  FILLER  POSITION(1)
    , filler_field_1  FILLER
    , filler_field_2  FILLER
    , day_of_week
    , month
    , day_of_month
    , time_of_day
    , year
    , run_ended_on            "TO_DATE((:month ||' '|| :day_of_month ||' '|| :time_of_day ||' '|| :year), 'Mon DD HH24:MI:SS YYYY')"
    INTO TABLE upload_log
    WHEN (1:18) = 'Elapsed time was: '
    FIELDS TERMINATED BY ':'
    (  upload_log_id   RECNUM
    , filler_field_0  FILLER  POSITION(1)
    , filler_field_1  FILLER
    , filler_field_2  FILLER
    , elapsed_time
    INTO TABLE upload_log
    WHEN (1:14) = 'CPU time was: '
    FIELDS TERMINATED BY ':'
    (  upload_log_id   RECNUM
    , filler_field_0  FILLER  POSITION(1)
    , filler_field_1  FILLER
    , filler_field_2  FILLER
    , cpu_time
    )Here are the basic table create scripts:
    TRUNCATE TABLE upload_log;
    DROP TABLE upload_log;
    CREATE TABLE upload_log
    (  upload_log_id      INTEGER
    , day_of_week        VARCHAR2(  3)
    , month              VARCHAR2(  3)
    , day_of_month       INTEGER
    , time_of_day        VARCHAR2(  8)
    , year               INTEGER
    , log_started_on     DATE
    , input_file_name    VARCHAR2(255)
    , table_name         VARCHAR2( 30)
    , action             VARCHAR2( 10)
    , number_of_records  INTEGER
    , run_began_on       DATE
    , run_ended_on       DATE
    , elapsed_time       VARCHAR2(  8)
    , cpu_time           VARCHAR2(  8)
    TRUNCATE TABLE upload_rejects;
    DROP TABLE upload_rejects;
    CREATE TABLE upload_rejects
    (  upload_rejects_id  INTEGER
    , record_number      INTEGER
    , reason             VARCHAR2(255)
    , error_code         VARCHAR2(  9)
    , error_desc         VARCHAR2(255)
    );Now, if I could only insert a single record to the upload_log table (per table logged); adding separate columns for skipped, read, rejected, discarded quantities. Any advice on how to use SQL Loader to do this (writing a procedure would be fairly simple, but I'd like to perform all of the work in one place if at all possible)?
    Thanks,
    Luke
    Edited by: Luke Mackey on Nov 12, 2009 4:28 PM

  • Can SQL*Loader Insert concatenated string into table

    Hi All,
    I want to insert a column, whose format is "abc" + to_char(sysdate,'YYYYMMDD'), into temp table. How can I do it? Thank you in advance.
    Best Regards,
    Sheng

    Hi Lukasz,
    Thank you for your help! The "abc" is a constant string, it isn't a column. And I use concat function to solve the problem. like this
    LOAD DATA
    INFILE data.txt
    INTO TABLE tmp_table
    fields terminated by "," optionally enclosed by '"'
    ( c1 "concat('abc',TO_CHAR(SYSDATE, 'YYYYMMDD'))"
    Sheng
    Edited by: Sheng on 2013-5-26 下午4:44

  • Using sql load insert multiple fields data into a single column in database

    Hi ,
    I have my log file in sun OS box something like this
    =======
    (07/29/2009 00:02:24.467) 367518 (07/29/2009 00:02:26.214) 949384011
    (07/29/2009 00:02:26.236) 3675 (07/29/2009 00:02:28.207) 949395117
    (07/29/2009 00:02:28.240) 337710 (07/29/2009 00:02:30.621) 949400864
    =============
    I am trying to insert the data into oracle data base as follows.
    =============================
    column1 : (07/29/2009 00:02:24.467)
    column2 : 367518
    column3 : (07/29/2009 00:02:26.214)
    column4 : 949384011
    ===========================
    Can anyone help me with the control file format?
    someone suggested me the code below.
    ==========
    LOAD DATA
    INFILE 'D:\work\load.txt'
    INTO TABLE sample
    (col1 POSITION(02:24) char,
    col2 POSITION(27:32) INTEGER EXTERNAL,
    col3 POSITION(35:57) CHAR,
    col4 POSITION(60:68) INTEGER EXTERNAL
    ===========
    but this works only for the fixed length data? Please help

    user11744904 wrote:
    Hi ,
    I have my log file in sun OS box something like this
    =======
    (07/29/2009 00:02:24.467) 367518 (07/29/2009 00:02:26.214) 949384011
    (07/29/2009 00:02:26.236) 3675 (07/29/2009 00:02:28.207) 949395117
    (07/29/2009 00:02:28.240) 337710 (07/29/2009 00:02:30.621) 949400864
    =============
    I am trying to insert the data into oracle data base as follows.
    =============================
    column1 : (07/29/2009 00:02:24.467)
    column2 : 367518
    column3 : (07/29/2009 00:02:26.214)
    column4 : 949384011
    ===========================
    Can anyone help me with the control file format?
    someone suggested me the code below.
    ==========
    LOAD DATA
    INFILE 'D:\work\load.txt'
    INTO TABLE sample
    (col1 POSITION(02:24) char,
    col2 POSITION(27:32) INTEGER EXTERNAL,
    col3 POSITION(35:57) CHAR,
    col4 POSITION(60:68) INTEGER EXTERNAL
    ===========
    but this works only for the fixed length data? Please helpIs the requirement to load all data in a single column or multiple columns? The thread subject and body are conflicting.

  • SQL Loader and INSERT Trigger

    I have problem and your help to solve it would be very much appreciated.
    I am uploading a text file with SQL Loader into a table. Since I used APPEND option in the Loader, I don't want records to be duplicated. So, I wrote a "BEFORE INSERT .. FOR EACH ROW" trigger to check whether that row already exists or not.
    For example, let us consider a table TEST as follows.
    Fld1     NUMBER(2);
    Fld2     VARCHAR2(10);
    Fld3     VARCHAR2(10);
    I have a trigger on this table.
    CREATE OR REPLACE TRIGGER Trg_Bef_Insert_Test
    BEFORE INSERT ON Test FOR EACH ROW
    DECLARE
    vCount NUMBER(2);
    DuplicateRow EXCEPTION;
    BEGIN
    SELECT Count(*) INTO vCount FROM Test
         WHERE fld1 || fld2 || fld3 = :new.fld1 || :new.fld2 || :new.fld3;
    IF vCount > 0 THEN
         RAISE DuplicateRow;
    END IF;
    EXCEPTION
    WHEN DuplicateRow THEN
         Raise_Application_Error (-20001,'Record already exists');
    WHEN OTHERS THEN
         DBMS_OUTPUT.PUT_LINE('ERROR : ' || SQLCODE || '; ' || SUBSTR(SQLERRM, 1, 150));
    END;
    Please refer to the following SQL statements which I executed in the SQL Plus.
    SQL> insert into test values (1,'one','first');
    1 row created.
    SQL> insert into test values (1,'one','first');
    insert into test values (1,'one','first')
    ERROR at line 1:
    ORA-20001: Record already exists
    ORA-06512: at "CAMELLIA.TRG_TEST", line 13
    ORA-04088: error during execution of trigger 'CAMELLIA.TRG_TEST'
    Would anyone tell me why do errors -6512 and -4088 occur ?
    Also, if you have any other suggestion to handle this situation, please let me know.
    By the way, I am using Oracle 8.1.7.
    Thank you.

    There are a few things wrong here, but you should really use a unique constraint for this.
    SQL> create table t (a number, b number, c number,
      2      constraint uk unique (a, b, c));
    Table created.Here's an example data file with 12 records three of which are duplicates.
    1,2,3
    3,4,5
    6,7,8
    3,2,1
    5,5,5
    3,4,5
    3,2,1
    1,1,1
    2,2,2
    6,7,8
    8,8,8
    9,9,9And a control file
    load data
    infile 'in.dat'
    append
    into table t
    fields terminated by ',' optionally enclosed by '"'
    (a, b, c)Running it with sql loader, inserts the nine records, outputs the three duplicates to a .bad file and logs all the errors in the .log file. No need for triggers or any code.
    $ sqlldr control=in.ctl
    Username:xxx
    Password:
    SQL*Loader: Release 9.2.0.1.0 - Production on Mon Apr 21 23:16:44 2003
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Commit point reached - logical record count 12
    $ cat in.bad
    3,4,5
    3,2,1
    6,7,8
    SQL> select * from t;
             A          B          C
             1          2          3
             3          4          5
             6          7          8
             3          2          1
             5          5          5
             1          1          1
             2          2          2
             8          8          8
             9          9          9
    9 rows selected.

  • Using SQL Loader to insert data based on conditionally statements

    I would like to use sql loader to insert records from a single text file into an Oracle database table. Sounds easy but the problem is that I need to check the existence of data in another table (Table A) before data can be loaded into Table B.
    Table A has two columns: dept_no (primary key value) and dept_name (char)
    Table B has five columns: emp_no (primary key value), dept_no (foreign key value to Table A), employee (char), job_title (char) and salary (number)
    Text File looks like this:
    Finance Jones President 10000
    HR Smith Admin 2000
    HelpDesk Jenkins Technician 3000
    Problem:
    1. I need sql loader to insert records into Table B by first checking if the first field in the file is in Table A.
    2. If value exists get it's dept_no value.
    3. If value doesn't exist discard record ( I might want to have sql loader insert a new record for this into Table A)
    4. Using value from #2, insert the value in Table B for dept_no column.
    5. Also assign a sequence value for the emp_no value in Table B.
    Any guidance is greatly appreciated.
    Thanks,

    Hello,
    I am not sure this is possible with SQL loader. I would rather use an external table based on your file.
    Then, I would use SQL to load your data into your table, based on your conditions.
    Your request is not very complicated, writing the SQL to do that will be really more simple than trying to do it with SQL loader.
    Hope it will help.
    Regards,
    Sylvie

  • SQL Loader - data exceeds maximum length

    I am having an issue with SQL Loader falsely reporting that a column is too long in a CSV upload file. The offending column, Notes, is defined in the staging table as VARCHAR2(1000). The text in the Notes column in the upload file for the record that is being rejected is only 237 characters long. I examined the raw data file with a hex editor and there are no special cahracters embedded in the column. The CSV upload was recreated but the false error remains.
    Any ideas what to check? Any suggestion appreciated.
    Here are the pertinent files.
    Control File:LOAD DATA
       INFILE 'Mfield_Upl.dat'
       BADFILE 'Mfield_Upl.bad'
       TRUNCATE
       INTO TABLE Mfield_UPL_Staging
       FIELDS TERMINATED BY ',' optionally enclosed by '"'
         ControlNo CHAR,
         PatientID CHAR,
         CollectDate DATE "MM/DD/YYYY",
         TestDate DATE "MM/DD/YYYY",
         AnalyteDesc CHAR,
         Results CHAR,
         HiLoFlag CHAR,
         LoRange CHAR,
         HiRange CHAR,
         UnitOfMeas CHAR,
         Comments CHAR,
         Notes CHAR,
         ClinicalEvent CHAR,
         OwnerLName CHAR,
         OwnerFName CHAR,
         PetName CHAR,
         AssecNo CHAR,
         SpecimenID CHAR
    {code}
    Staging Table:{code}
    CREATE TABLE Mfield_UPL_Staging
        ControlNo      VARCHAR2(20),
        PatientID      VARCHAR2(9),
        CollectDate    DATE,
        TestDate       DATE,
        AnalyteDesc    VARCHAR2(100),
        Results        VARCHAR2(100),
        HiLoFlag       CHAR(10),
        LoRange        VARCHAR2(15),
        HIRange        VARCHAR2(15),
        UnitOfMeas     VARCHAR2(25),
        Comments       VARCHAR2(100),
        Notes          VARCHAR2(1000),
        ClinicalEvent  VARCHAR2(20),
        OwnerLName     VARCHAR(50),
        OwnerFName     VARCHAR(50),
        PetName        VARCHAR(50),
        AssecNo        NUMBER(10),
        SpecimenID     NUMBER(10)
    {Code}
    Error Log File:{code}
    SQL*Loader: Release 9.2.0.1.0 - Production on Wed Aug 11 08:22:58 2010
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Control File:   Mfield_UPL_CSV.ctl
    Data File:      Mfield_UPL.dat
      Bad File:     Mfield_Upl.bad
      Discard File:  none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 50
    Bind array:     64 rows, maximum of 256000 bytes
    Continuation:    none specified
    Path used:      Conventional
    Table MFIELD_UPL_STAGING, loaded from every logical record.
    Insert option in effect for this table: TRUNCATE
       Column Name                  Position   Len  Term Encl Datatype
    CONTROLNO                           FIRST     *   ,  O(") CHARACTER           
    PATIENTID                            NEXT     *   ,  O(") CHARACTER           
    COLLECTDATE                          NEXT     *   ,  O(") DATE MM/DD/YYYY     
    TESTDATE                             NEXT     *   ,  O(") DATE MM/DD/YYYY     
    ANALYTEDESC                          NEXT     *   ,  O(") CHARACTER           
    RESULTS                              NEXT     *   ,  O(") CHARACTER           
    HILOFLAG                             NEXT     *   ,  O(") CHARACTER           
    LORANGE                              NEXT     *   ,  O(") CHARACTER           
    HIRANGE                              NEXT     *   ,  O(") CHARACTER           
    UNITOFMEAS                           NEXT     *   ,  O(") CHARACTER           
    COMMENTS                             NEXT     *   ,  O(") CHARACTER           
    NOTES                                NEXT     *   ,  O(") CHARACTER           
    CLINICALEVENT                        NEXT     *   ,  O(") CHARACTER           
    OWNERLNAME                           NEXT     *   ,  O(") CHARACTER           
    OWNERFNAME                           NEXT     *   ,  O(") CHARACTER           
    PETNAME                              NEXT     *   ,  O(") CHARACTER           
    ASSECNO                              NEXT     *   ,  O(") CHARACTER           
    SPECIMENID                           NEXT     *   ,  O(") CHARACTER           
    Record 1042: Rejected - Error on table MFIELD_UPL_STAGING, column NOTES.
    Field in data file exceeds maximum length
    Table MFIELD_UPL_STAGING:
      3777 Rows successfully loaded.
      1 Row not loaded due to data errors.
      0 Rows not loaded because all WHEN clauses were failed.
      0 Rows not loaded because all fields were null.
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Try:
    -- Etc ...
      Notes CHAR(1000),
    -- Etc ...SQL*Loader limits string buffer to 256 unless specified different.
    :p

  • Importing oracle.sql.BLOB through SQL Loader

    Hello,
    Currently the system we have creates .sql files and executes them. This takes a long time, so we're attempting to change to using SQL Loader. The one problem I'm having that I can't seem to fix is finding out how to imitate the behavior of this SQL statement through SQL Loader:
    INSERT INTO KRSB_QRTZ_BLOB_TRIGGERS (BLOB_DATA,TRIGGER_GROUP,TRIGGER_NAME)
    VALUES (oracle.sql.BLOB@515263,'KCB-Delivery','PeriodicMessageProcessingTrigger')
    I tried creating a lobfile and placing the text oracle.sql.BLOB@515263 within it this way
    INTO TABLE KRSB_QRTZ_BLOB_TRIGGERS
    WHEN tablename = 'KRSB_QRTZ_BLOB_TRIGGERS'
    FIELDS TERMINATED BY ',' ENCLOSED BY '##'
    TRAILING NULLCOLS
    tablename FILLER POSITION(1),
    TRIGGER_NAME CHAR(80),
    TRIGGER_GROUP CHAR(80),
    ext_fname FILLER,
    BLOB_DATA LOBFILE(ext_fname) TERMINATED BY EOF
    However, as expected, it merely loaded the text "oracle.sql.BLOB@515263" into the database. So does anyone have any ideas of how to imitate that insert statement through SQL Loader? The only information I have available is the string "oracle.sql.BLOB@515263", no other files or anything to aid with actually getting the binary data.
    When the .sql file is run with that insert statement in it, a 1.2kb BLOB is inserted into the database versus a 22 byte BLOB that contains nothing useful when done through SQL Loader.
    Alex

    My preference is DBMS_LOB.LOADFROMFILE
    http://www.morganslibrary.org/reference/dbms_lob.html
    did you try it?

  • Sql Loader Performance

    Hi
    i have some question about SQL Loader. i have to find answers but did not get from Google or Documentation. i want to know that is there any way to check whether Sql loader inserting records with Direct path or Conventional path. As we know there are restriction in Direct load. Direct-path inserts do not support all objects that conventional inserts do. Their functionality
    is restricted. If the database engine is not able to execute a direct-path insert, the operation is silently converted into a conventional insert. i have instruct Sql loader to insert using Direct=true and parallel as well. but it take 15 mint to loader 4 million record in table. i have observed its transfer rate is bit slow. i have oracle 11R2 on windows 2008 with 40GB RAM and SAN. how can i verify during execution either Sql loader load user Direct path or silently converted it conventional path. here is my sample control file. function used in control file will convert direct path to conventional?
    /c sqlldr userid='MSNV5Star/Aa123456@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=srv01)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl)))' control='C:\ControlFile.txt' log='C:\ Final Data.log' bad= 'C:\ Final Data.bad'  direct=true  PARALLEL=TRUE  skip=1 Errors=5000000
    LOAD DATA 
    INFILE 'C:\adeel loading\in\A06052010.txt'APPEND
    INTO TABLE GN_FILE_DATA_TABLE
    FIELDS TERMINATED BY "     " TRAILING NULLCOLS
    Operational_Date "to_date(:Operational_Date, 'YYYYMMDD')" ,
    Store_Code "TRIM(:Store_Code)" ,
    Txn_Void_Flag "TRIM(:Txn_Void_Flag)" ,
    Txn_Staff_Flag "TRIM(:Txn_Staff_Flag)" ,
    Txn_Aborted_Flag "TRIM(:Txn_Aborted_Flag)"     Edited by: Oracle Studnet on May 30, 2011 7:18 AM

    Pl do not post duplicates - sql Loader Performance
    Srini

  • Load blank or null lines with SQL*Loader

    I want to retain blank (or null) lines present in the input file, which SQL*Loader retains. My control file looks like this:
    LOAD DATA
    INFILE 'c:\sdfload\compounds.sdf'
    BADFILE 'c:\sdfload\compounds.log'
    INTO TABLE sdfile
    ( rid "sdf_seq.nextval",
    sdfrec POSITION (1:600) NULLIF rid=BLANKS
    The first five lines of input look like (the blank lines look to be end-of-line or tab characters).
    Marvin 02171107552D
    38 43 0 0 0 0 999 V2000
    1.3379 -2.6605 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
    The output looks like this (first and third records excluded)
    RID SDFREC
    1 Marvin 02171107552D
    2 38 43 0 0 0 0 999 V2000
    3 1.3379 -2.6605 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
    How do I get output that looks like this?
    RID SDFREC
    1
    2 Marvin 02171107552D
    3
    4 38 43 0 0 0 0 999 V2000
    5 1.3379 -2.6605 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
    Any help or suggestions will be greatly appreciated!
    -Mike

    You might want to check an older post: SQL LOADER Insert Rows blank

  • SQL*Loader-929: Error parsing insert statement for table

    Hi,
    I get the following error with SQL*Loader:
    Table MYTABLE loaded from every logical record.
    Insert option in effect for this table: INSERT
    Column Name Position Len Term Encl Datatype
    IDE FIRST * ; CHARACTER
    SQL string for column : "mysequence.NEXTVAL"
    CSI_NBR 1:10 10 ; CHARACTER
    POLICY_NBR 11:22 12 ; CHARACTER
    CURRENCY_COD 23:25 3 ; CHARACTER
    POLICY_STAT 26:27 2 ; CHARACTER
    PRODUCT_COD 28:35 8 ; CHARACTER
    END_DAT 44:53 10 ; CHARACTER
    FISCAL_COD 83:83 1 ; CHARACTER
    TOT_VAL 92:112 21 ; CHARACTER
    SQL*Loader-929: Error parsing insert statement for table MYTABLE.
    ORA-01031: insufficient privileges
    I am positive that I can SELECT the sequence and INSERT into the table with the user invoking sql*loader.
    Where does that "ORA-01031" come from?
    Regards
    ...

    Options:
    1) you are wrong about privileges OR
    2) you have the privilege only when you connect via SQL*Plus (or whichever other tool you used to test the insert).
    Is it possible that during your test you enabled the role which granted you the INSERT privilege - and that SQL*Loader doesn't do this?
    Can you see the table in this list?
    select *
    from user_tab_privs_recd
    where table_name='MY_TABLE'
    and owner='table owner whoever';
    select *
    from user_role_privs;Any roles where DEFAULT_ROLE is not YES?
    HTH
    Regards Nigel

  • SQL Loader need to insert the input filename into output table

    Hi All,
    I've a small problem with my SQL Loader query. My sql loader should read a file and write the data into a file. Also this sql loader should read the filename and write it into the same table. Here's my control file code:
    LOAD DATA
    APPEND
    INTO TABLE XXMW_STG_SOH_HEADER_UK
    WHEN (1:4) = '7010'
    TRAILING NULLCOLS
    (WH POSITION(5:6)
    ,ITEM POSITION(9:26)
    ,PRODUCT_STATUS POSITION(33:34)
    ,BALANCE_ON_HAND POSITION(35:43)
    ,TO_SHIP_QTY POSITION(71:79)
    ,RUSH_TO_SHIP_QTY POSITION(80:88)
    ,RESERVED_QTY POSITION(175:183)
    ,SNAPSHOT_DATE POSITION(134:143) CHAR "TO_DATE(:SNAPSHOT_DATE,'YYYY-MM-DD')"
    ,SNAPSHOT_TIME POSITION(144:151) CHAR "TO_DATE(:SNAPSHOT_TIME,'HH24:MI:SS')"
    ,PROCESSED_IND CONSTANT "N"
    ,PROCESSED_DATETIME SYSDATE
    ,_FILENAME POSITION(184) CHAR TERMINATED BY WHITESPACE_
    My program should read the filename dynamically (means a shell script is calling this .ctl file which is reading multiple input files) and insert into the filename field in xxmw_stg_soh_header_uk table.
    Please let me know for any questions/clarifications.
    Regards,
    Debabrata

    While I think Blu's suggestion to use external tables is better, if you need to use SQL Loader, you could do something like this.
    Create a "generic" control file with a placeholder for the filename, something like:
    LOAD DATA
    APPEND
    INTO TABLE XXMW_STG_SOH_HEADER_UK
    WHEN (1:4) = '7010'
    TRAILING NULLCOLS (
       WH POSITION(5:6),
       ITEM POSITION(9:26),
       PRODUCT_STATUS POSITION(33:34),
       BALANCE_ON_HAND POSITION(35:43),
       TO_SHIP_QTY POSITION(71:79),
       RUSH_TO_SHIP_QTY POSITION(80:88),
       RESERVED_QTY POSITION(175:183),
       SNAPSHOT_DATE POSITION(134:143) CHAR "TO_DATE(:SNAPSHOT_DATE,'YYYY-MM-DD')",
       SNAPSHOT_TIME POSITION(144:151) CHAR "TO_DATE(:SNAPSHOT_TIME,'HH24:MI:SS')",
       PROCESSED_IND CONSTANT "N",
       PROCESSED_DATETIME SYSDATE,
       FILENAME CONSTANT ":FILE"I am assuming that your shell script is looping through a set of file names and loading each one. So make your shell script look something like:
    FILES=`ls *.txt`
    CTL=generic.CTL
    for f in $FILES
    do
       cat $CTL| sed "s/:FILE/$f/g" > $f.ctl
       sqlldr usr/passwd control=$f.ctl data=$f
    doneThe line cat $CTL| sed "s/:FILE/$f/g" > $f.ctl will create a "custom" control file for each file and add the filename as a constant at the end.
    John

  • SQL Loader and Insert Into Performance Difference

    Hello All,
    Im in a situation to measure performance difference between SQL Loader and Insert into. Say there 10000 records in a flat file and I want to load it into a staging table.
    I know that if I use PL/SQL UTL_FILE to do this job performance will degrade(dont ask me why im going for UTL_FILE instead of SQL Loader). But I dont know how much. Can anybody tell me the performance difference in % (like 20% will decrease) in case of 10000 records.
    Thanks,
    Kannan.

    Kannan B wrote:
    Do not confuse the topic, as I told im not going to use External tables. This post is to speak the performance difference between SQL Loader and Simple Insert Statement.I don't think people are confusing the topic.
    External tables are a superior means of reading a file as it doesn't require any command line calls or external control files to be set up. All that is needed is a single external table definition created in a similar way to creating any other table (just with the additional external table information obviously). It also eliminates the need to have a 'staging' table on the database to load the data into as the data can just be queried as needed directly from the file, and if the file changes, so does the data seen through the external table automatically without the need to re-run any SQL*Loader process again.
    Who told you not to use External Tables? Do they know what they are talking about? Can they give a valid reason why external tables are not to be used?
    IMO, if you're considering SQL*Loader, you should be considering External tables as a better alternative.

  • SQL Loader - want to access data from .txt file but don't want to insert

    Hello,
    I have situation where I have some data in .txt file and I have to load that data into one of my table.
    My problem is I have fundtion get_id(a,b,c) in database which I have to call while loading the data to find out value of x.
    I have value of a, b and c in txt file which I can access it using POSITION(N:M) in sql loader, but After accessing that value I just want to past to get_id() function and dont want to insert into sql loader.
    any help

    My control file is as below
    Following field is not in database but I need to pass the value to the function to get a ESC_USER_ID. any help
    OFFICE_NUM      filler POSITION(32:35) ,
    STATION_DESK      filler POSITION(45:48),
    LOAD DATA
    INFILE REFERRALs.TXT
    BADFILE REFERRAL_LOAD.BAD
    DISCARDFILE REFERRAL_LOAD.DIS
    INSERT
    INTO TABLE REFERRAL
    EVALUATE CHECK_CONSTRAINTS REENABLE DISABLED_CONSTRAINTS
    TRAILING NULLCOLS
    ID                    sequence (1,1),
    JOB_ID                    POSITION (16:22) "GET_JOB_ID(:JOB_ID)"      ,
    CUS_ID                    POSITION (23:31) "GET_CUS_ID(:CUS_ID)"     ,
    STATUS_LU               CONSTANT 'F'                    ,     
    REQUEST_USER_TYPE_LU          CONSTANT 'S'                    ,
    OFFICE_NUM      filler POSITION(32:35) ,
    STATION_DESK      filler POSITION(45:48),
    REQUEST_USER_ID          POSITION(143:149) "GET_ESCUSER_ID(OFFICE_NUM,STATION_DESK,:REQUEST_USER_ID)"     ,
    REQUEST_DT               POSITION (37:44) "to_date(:REQUEST_DT,'YYYY/MM/DD')"     ,
    REVIEW_USER_ID               FILLER                         ,
    REVIEW_DT               FILLER                         ,
    REFUSE_REASON_LU          FILLER                         ,
    RESULT_LU               POSITION (97:97)               ,
    NOTIFY_STATUS_LU          FILLER                         ,
    NOTIFY_DT               FILLER                         ,
    APPOINTMENT_DT               POSITION (106:113) "to_date(:APPOINTMENT_DT,'YYYY/MM/DD')"     ,
    RESULT_DT               POSITION (98:105) "to_date(:RESULT_DT,'YYYY/MM/DD')"     ,
    NO_MATCH_IND               CONSTANT 'N'
    )

Maybe you are looking for