SQL LOADER "LOGICAL COMMIT"

Hello ,
After each successful execution of sql loader ,it implicitly commits the underlying transactions .
Why this implicit commit is happening and Can disable this auto commit feature of sql loader ?
Thanks

Hi ,
We cannot stop the commit option in sqlloqder.
By using the ROWS parameter we can control the feature
For eg rows=200
The records will be committed after every 200 records are over only.
Thanks
USR0072

Similar Messages

  • SQL loader and commit

    Hi,
    I am trying to execute a sql loader script that populates many tables. The order of the tables in the script is very important because the table of the last table has a constraint with the first table of the script. So I need that sqlloader executes a commit after the filling of the first tables because if sql loader executes the script simply as it is written the last tables launches an error because the constraint is violated (the last table sees the first one empty).
    How can I force a commit after a filling in sql loader?
    The sctructure of the tables was not defined by me so I must not modify it (constraint included).
    Thanks, bye bye.

    Hi,
    If you have to enable/disable manually the constraints you can execute:
    DECLARE
      v_ds_action VARCHAR2(7);
    BEGIN
      v_ds_action := 'DISABLE';
        FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'R') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
      FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'C') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
    FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'U') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
      FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'P') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
    END;
    DECLARE
      v_ds_action VARCHAR2(7);
    BEGIN
      v_ds_action := 'ENABLE';
      FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'P') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
      FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'U') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
      FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'C') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
      FOR reg IN (SELECT * FROM user_constraints uc WHERE uc.constraint_type = 'R') LOOP
        EXECUTE IMMEDIATE 'ALTER TABLE ' || reg.table_name || ' ' ||
                          v_ds_action || '  CONSTRAINT ' || reg.constraint_name;
      END LOOP;
    END;
    /Regards,

  • Help Required with PL/SQL loading logic

    Hi All,
    We have a simple pl/sql code which does loading(insertions) of records into the table. This pl/sql code actually refers to an translation website URL(microsoft based) and inserts the translated text into our table. What happens is sometimes this URL gets blocked out due to some issue. So we are forced to restart our entire operation of loading once again. Actually we have a commit at the end(outside the loop). on the other hand we cant keep commit inside the loop as it may pose an overhead to performance since its commiting once every insert happens.
    What we are expecting is something like this. Say we have 10,000 records. the loading fails at 5500 record. next time when we start again we want to start from 5501 record and NOT from beginning. In informatica kind of ETL tools we have an option to do this. However not sure if we can do this through PL/SQL.
    we thought of keeping counter variable and keep it incrementing for each and every insert happens. but before doing this we have to order by our table according to primary key. This is taking huge amount of time since the table is very big.
    can you please tell any alternative to this?
    Regards,
    Paul

    If I understand correctly, you are doing something as follows:
    // process a defined data set
    for c in (select .. some data... ) 
    loop
        // translate the data (via a web service call)
        Translate( c, translatedOutput )
        // insert the translated data
        insert into some_table translatedOutput
    end loop
    commitIn principle, nothing wrong with this approach. And yes, committing inside the loop for every x number of rows will increase the complexity of code and could perhaps violate ANSI SQL standards of fetching across commits.
    A better approach would be to consider parallelising this process. Run multiple copies of that code - but provide each copy of the code with a small and unique data set to process. So instead of doing 10,000 rows in serial, you schedule a 100 jobs and give each a unique set of a 100 rows to translate.
    Let's say your job queue size is set to 20. This means up to 20 of these processes will run in parallel. Should one fail, the job manager will automatically reschedule it for execution (up to 16 times after which it will be marked as broken).
    So not only does this type of approach enables you spread the processing load, it also enables you to scale your processing (you can handle much larger data volumes like this, and more powerful server h/w will enable you to use more parallel processes). In addition, restart is automated courtesy of the Oracle job manager.
    Compare this type approach with committing inside a loop.. The latter buys you what ito flexibility and performance and scalability? Nothing really - it only makes the process a lot more complex as it needs to be able to correctly restart after a failure. You will not be able to process bigger volumes of data. You will not be able to increase existing performance.
    One needs to carefully consider the approach used to processing data - serialisation is inherently limited. Restarting serialised processes is difficult and complex.

  • SQL LOADER  message : Point de validation COMMIT atteint - nombre d'enreg

    Hello
    I am loading a csv file into an oracle table via SQL LOADER
    Each time i invoke it i get the folowing message :
    SQL LOADER message : Point de validation <COMMIT> atteint - nombre d'enregis. logiques 52. (i am french version of apex)
    And the table is left empty.
    The translation of the above message is :
    SQL LOADER Validation Point <COMMIT> reached. number of logical records 52
    What doese it mean ?
    Thanks in advance.

    Yes
    my table is empty and
    and this is my control file :
    load data
    infile 'i:\csvs\mvh051.csv'
    into table mvhist051
    fields terminated by ';' optionally enclosed by '"'
    (ETABLI,NUPIECE,NUMLIGNE,DATEOP,JOURNAL,COMPTE,CODEN,LIBELLE,MONTANT,SENS,DATEVALEUR,OPERATION,NPIECE,CORIG,SOLDE,MVAPUR)
    hear is a sample of bide file :
    5100;2052;1;01/01/2005;ARB;1120060;0;report de solde 2004;6122867,27;D;01/01/2005;98;;1
    5100;2053;1;01/01/2005;ARB;1120070;0;report de solde 2004;223639,17;D;01/01/2005;98;;1
    5100;2054;1;01/01/2005;ARB;1261000;0;report de solde 2004;4680204207,00;D;01/01/2005;98;;1
    5100;2055;1;01/01/2005;ARB;1271100;0;report de solde 2004;81895715591,44;D;01/01/2005;98;;1
    ETABLI;NUPIECE;NUMLIGNE;DATEOP;JOURNAL;COMPTE;CODEN;LIBELLE;MONTANT;SENS;DATEVALEUR;OPERATION;NPIECE;CORIG;SOLDE;MVAPUR
    Please not that the last line is the heading columns names. I dont under stand why
    it is copied.

  • Substitution for logical OR usage in control file of sql loader

    Hi,
    can anyone suggest me a substituion method to use the functionality of logical OR in control file developed for sql loader.
    Ex:
    load data
    append
    into table ABC
    when (1:2) = 'AD'
    --AND ((27:28)= '01' OR (27:28)= '02')
    AND (1222:1222) = '1'
    trailing nullcols
    Note: condition commented in the above example need to be replaced.
    one way of doing it can be splitting blocks for each condition.
    Then it will look like:
    load data
    append
    into table ABC
    when (1:2) = 'AD'
    AND (27:28)= '01'
    AND (1222:1222) = '1'
    trailing nullcols
    into table ABC
    when (1:2) = 'AD'
    AND (27:28)= '02'
    AND (1222:1222) = '1'
    trailing nullcols
    So, i'm looking for a better way than this, as i cannot work with the above
    splitting logic because i'm dealing with lot many conditions.
    Thanx inadvance
    Kishore

    Hi,
    can anyone suggest me a substituion method to use the functionality of logical OR in control file developed for sql loader.
    Ex:
    load data
    append
    into table ABC
    when (1:2) = 'AD'
    --AND ((27:28)= '01' OR (27:28)= '02')
    AND (1222:1222) = '1'
    trailing nullcols
    Note: condition commented in the above example need to be replaced.
    one way of doing it can be splitting blocks for each condition.
    Then it will look like:
    load data
    append
    into table ABC
    when (1:2) = 'AD'
    AND (27:28)= '01'
    AND (1222:1222) = '1'
    trailing nullcols
    into table ABC
    when (1:2) = 'AD'
    AND (27:28)= '02'
    AND (1222:1222) = '1'
    trailing nullcols
    So, i'm looking for a better way than this, as i cannot work with the above
    splitting logic because i'm dealing with lot many conditions.
    Thanx inadvance
    Kishore

  • SQL Loader with decimal commas

    Dear All,
    I am loading data for a German client and the delivered files contain numeric data with decimal commas. For example 123,5 instead of 123.5
    I've been googling like mad on this one and there is a lot of chatter about setting NLS_LANG and/or NLS_NUMERIC_CHARACTERS but none of this seems to work in the SQL Loader environment.
    I imagine that I will end up cobbling together a complicated thing with TO_NUMBER or with another function but I really can't believe that SQL Loader doesn't have a simple switch to flip from point to comma.
    Or have I overlooked something?
    Any tips would be a great help.
    Regards,
    Alan Searle

    I am on a client's PC and don't have access to administrative settings.
    And also, I cannot be sure that whoever runs the load function in the future will check this.
    It is therefore important that I find a way to set this in SQL Loader without any other dependencies.
    I think I will probably end up processing it as a string and then translating it to numeric. But this seems like a sledge hammer to crack a nut.
    Regards and thanks,
    Alan

  • Extracting Multiple Logical Records through sql loader

    Hello gurus,
    I have few questions regarding the sql loader. I m totally new to this i have never used, this is the first time i m using
    1.
    How do i find the position number of the charcter or a number ? do i need to physically count the position ? is ther any specific way of counting or use textpad to do that ?
    I know it sounds like silly question... but i wanted to know if there is any better way of doing it
    2.
    example data
    1119 Smith      1120 Yvonne
    1121 Albert     1130 Thomas
    The following control file extracts the logical records:
    INTO TABLE emp
         (empno POSITION(1:4)  INTEGER EXTERNAL,
          ename POSITION(6:15) CHAR)
    INTO TABLE emp
         (empno POSITION(17:20) INTEGER EXTERNAL,
          ename POSITION(21:30) CHAR)---
    2. Can you please expalin me what does the "null if deptno = blanks " ?
    deptno POSITION(1:2)  INTEGER EXTERNAL(2)
                  NULLIF deptno=BLANKS,I really appriciate it ~
    Thanks

    Hi,
    The NULLIF means load blanks as NULL
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_field_list.htm#sthref1129
    Not sure I understand your first question. You must of course know the format of the file, TextPad could be an ok tool for determining that format for a fixed column width file.
    Regards
    Peter

  • Sql*loader-604 Error occurred on an attempt to commit

    Hi,
    Iam trying to insert data in to dept table using sqlloader.It worked fine for first 2 attempts but when iam trying it later its giving an error.
    E:\ sqlldr userid=scott/tiger@test,control='E:\oracle\dept.ctl'
    sql*loader-604 Error occurred on an attempt to commit
    ora-03114: not connected to oracle
    Regards,
    Krithika

    ora-03114: not connected to oracle
    Your DBA might have wriiten a procedure to Kill an Oracle session if idle for 15 mins or so or he might have killed the session for some maintenance purpose and that to forcefully . Try reconnectiing again

  • I parallelize the use of SQL*Loader.But it always commit per 89 rows

    I parallelize the use of SQL*Loader. But it always commit per 89 rows. How can I set Commit Row Number?

    enlarge the BINDSIZE= and ROWS= option or better use DIRECT=TRUE
    (and no need to parallelize [whatever this is in your case])

  • [svn:osmf:] 14580: Commit example showing how to perform additional load logic via a ProxyElement .

    Revision: 14580
    Revision: 14580
    Author:   [email protected]
    Date:     2010-03-04 09:28:35 -0800 (Thu, 04 Mar 2010)
    Log Message:
    Commit example showing how to perform additional load logic via a ProxyElement.  The AsynchLoadingProxyElement (and its corresponding LoadTrait) load the proxied element, but doesn't expose its READY state to the outside world until it performs its own load operation (in this case it just runs a Timer).  Include minor fix to other example.
    Modified Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/org/osmf/examples/AllExamples.as
        osmf/trunk/apps/samples/framework/ExamplePlayer/org/osmf/examples/loaderproxy/VideoProxyE lement.as
    Added Paths:
        osmf/trunk/apps/samples/framework/ExamplePlayer/org/osmf/examples/loaderproxy/AsynchLoadi ngProxyElement.as
        osmf/trunk/apps/samples/framework/ExamplePlayer/org/osmf/examples/loaderproxy/AsynchLoadi ngProxyLoadTrait.as

    Nope, what for?
    If you know what you are doing and you discharge yourself there is no need for such.
    BTW, those bands are not that safe, if you use them wrongly you can electrocute yourself pretty easily

  • How do i map one field to another in control file via SQL Loader

    Can someone please reply back to this question
    Hi,
    I have a flat file (student.dat delimiter %~| ) using control file (student.ctl) through sql loader. Here are the details.
    student.dat
    student_id, student_firstname, gender, student_lastName, student_newId
    101%~|abc%~|F %~|xyz%~|110%~|
    Corresponding table
    Student (
    Student_ID,
    Student_FN,
    Gender,
    Student_LN
    Question:
    How do i map student_newId field to student_id field in STUDENT DB table so that new id should be inserted in student_id column. How do i specify the mapping in control file. I dont want to create a new column in student table. Please let me know the best way to do this.
    Can someone please reply back to this question.
    My approach:
    In control file i will sepecify the below, Is this a best approach?. Do we have any othe way?
    STUDENT_ID *(:STUDENT_NEWID)*,
    STUDENT_FN,
    GENDER,
    STUDENT_LNAME,
    STUDENT_NEWID BOUNDFILLER
    Thanks
    Sunil
    Edited by: 993112 on Mar 13, 2013 12:28 AM
    Edited by: 993112 on Mar 13, 2013 12:30 AM
    Edited by: 993112 on Mar 13, 2013 12:31 AM
    Edited by: 993112 on Mar 18, 2013 2:52 AM

    OK, ok...
    Here is the sample data:
    101%~|abc%~|F %~|xyz%~|110%~|
    102%~|def%~|M %~|pqr%~|120%~|
    103%~|ghi%~|M %~|stu%~|130%~|
    104%~|jkl%~|F %~|vwx%~|140%~|
    105%~|mno%~|F %~|yza%~|150%~|Here is the control file:
    LOAD DATA
    INFILE student.dat
    TRUNCATE INTO TABLE STUDENT
    FIELDS TERMINATED BY '%~|' TRAILING NULLCOLS
      student_old  FILLER
    , student_fn
    , gender
    , student_ln
    , student_id
    )And here is the execution:
    SQL> CREATE TABLE student
      2  (
      3    student_id   NUMBER
      4  , student_fn   VARCHAR2 (10)
      5  , gender       VARCHAR2 (2)
      6  , student_ln   VARCHAR2 (10)
      7  );
    Table created.
    SQL>
    SQL> !sqlldr / control=student.ctl
    SQL*Loader: Release 11.2.0.3.0 - Production on Tue Mar 19 14:37:31 2013
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    Commit point reached - logical record count 5
    SQL> select * from student;
    STUDENT_ID STUDENT_FN                     GENDER STUDENT_LN
           110 abc                            F      xyz
           120 def                            M      pqr
           130 ghi                            M      stu
           140 jkl                            F      vwx
           150 mno                            F      yza
    SQL>:p

  • Error in loading data using SQL loader

    I am getting a error like ‘SQL*Loader -350 syntax error of illegal combination of non-alphanumeric characters’ while loading a file using SQL loader in RHEL. The command used to run SQL*Loader is:
    Sqlldr userid=<username>/<password> control =data.ctl
    The control file, data.ctl is :
    LOAD data
    infile '/home/oraprod/data.txt'
    append  into table test
    empid terminated by ',',
    fname terminated by ',',
    lname terminated by ',',
    salary terminated by whitespace
    The data.txt file is:
    1,Kaushal,halani,5000
    2,Chetan,halani,1000
    I hope, my question is clear.
    Please revert with the reply to my query.
    Regards

    Replace ''{" by "(" in your control file
    LOAD data
    infile 'c:\data.txt'
    append  into table emp_t
    empid terminated by ',',
    fname terminated by ',',
    lname terminated by ',',
    salary terminated by whitespace
    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 point reached - logical record count 1
    Commit point reached - logical record count 2
    SQL> select * from emp_t;
         EMPID FNAME                LNAME                    SALARY
             1 Kaushal              halani                     5000
             2 Chetan               halani                     1000
    Best regards
    Mohamed Houri

  • SQL Loader and weird source file structure

    I am familiar with using SQL Loader to process comma or tab delimited text files into proper table data. But how do you process "positionally delimited" files?!
    I mean, I have a text file which looks like this:
    Item A
    ---attribute1
    ---attribute2
    ---attribute3
    ---attribute4
    Item B
    ---attribute1
    ---attribute2
    ---attribute3
    ---attribute4
    Item C
    ---attribute1
    ---attribute2
    ---attribute3
    ---attribute4
    And so on. How do I tell SQL Loader, 'rows 1, 6 and 11 are the first column in the table; rows 2, 7 and 12 and the second column; rows 3, 8, 13 are the third and so on? I want to end up with data in the form
    Item A Attribute1 Attribute2 Attribute3 Attribute 4
    Item B Attribute1 Attribute2 Attribute3 Attribute 4
    Item C Attribute1 Attribute2 Attribute3 Attribute 4
    Is such a thing even possible with SQL Loader?

    If your data is exactly in that format like in sample provided by Enrique, you can try to play with that certain data pattern. Again, based on previous example:
    ~ >cat data.dat
    map1
        615050: ( 95, 83, 68) #5F5344 rgb(95,83,68)
        605728: ( 36, 27, 22) #241B16 rgb(36,27,22)
        225834: (154,107, 84) #9A6B54 rgb(154,107,84)
        176305: (218,187,155) #DABB9B rgb(218,187,155)
        141083: (188,142,111) #BC8E6F rgb(188,142,111)
    map2
        615050: ( 95, 83, 68) #5F5344 rgb(95,83,68)
        605728: ( 36, 27, 22) #241B16 rgb(36,27,22)
        225834: (154,107, 84) #9A6B54 rgb(154,107,84)
        176305: (218,187,155) #DABB9B rgb(218,187,155)
        141083: (188,142,111) #BC8E6F rgb(188,142,111)
    map3
        615050: ( 95, 83, 68) #5F5344 rgb(95,83,68)
        605728: ( 36, 27, 22) #241B16 rgb(36,27,22)
        225834: (154,107, 84) #9A6B54 rgb(154,107,84)
        176305: (218,187,155) #DABB9B rgb(218,187,155)
        141083: (188,142,111) #BC8E6F rgb(188,142,111)
    ~ >cat data.ctl
    LOAD DATA
    INFILE "data.dat" "str '\nm'"
    DISCARDFILE "data.dsc"
    DISCARDMAX 999
    REPLACE
    -- CONCATENATE 6
    INTO TABLE data
    fields terminated by X'0a' trailing nullcols
    ( item char "replace('m'||:item,'mm','m')",
      attrib1 char,
      attrib2 char,
      attrib3 char,
      attrib4 char,
      attrib5 char
    ~ >sqlplus scott/tiger
    SQL*Plus: Release 10.2.0.4.0 - Production on Wed Oct 15 16:27:25 2008
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> select count(*) from data;
      COUNT(*)
             0
    SQL> !sqlldr userid=scott/tiger control=data.ctl
    SQL*Loader: Release 10.2.0.4.0 - Production on Wed Oct 15 16:28:29 2008
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Commit point reached - logical record count 2
    Commit point reached - logical record count 3
    SQL> col item for a4
    SQL> col attrib1 for a50
    SQL> col attrib2 for a50
    SQL> select item,attrib1,attrib2 from data;
    ITEM ATTRIB1                                            ATTRIB2
    map1     615050: ( 95, 83, 68) #5F5344 rgb(95,83,68)        605728: ( 36, 27, 22) #241B16 rgb(36,27,22)
    map2     615050: ( 95, 83, 68) #5F5344 rgb(95,83,68)        605728: ( 36, 27, 22) #241B16 rgb(36,27,22)
    map3     615050: ( 95, 83, 68) #5F5344 rgb(95,83,68)        605728: ( 36, 27, 22) #241B16 rgb(36,27,22)
    SQL>As you see, i loaded on linux, on windows you may slightly adjust controlfile to reflect end of lines...
    Best regards
    Maxim

  • SQL Loader and Batch ID

    Hi All,
    In our application, we are allowing user to upload data using excel sheet in UI.
    We are using PHP script in UI and using SQL Loader to load data from excel sheet to temp_table.
    The temp_table has a primary key.
    Here my question is , Is there any way to put some batch id for every upload in that table in automatic way ?
    so that we can easily extract the data by using batch id
    we are using Oracle 11g.

    All that does is load a constant value, in which case you might as well just use constant 815 in your control file. If you want to automatically increment the value for each batch, then you need to use a different method.
    Please see the example below. Prior to each data load, it loads the next value of the sequence into a separate table, then selects that value during the data load. Note that a SQL*Loader expression that uses select must be enclosed within parentheses within 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 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.

Maybe you are looking for

  • Send IDoc to Multiple Ports

    Hi, I have a custom IDoc message type YYY17101[Custom Type]. I need to send IDoc using this message type to 2 different rfc destination. The two RFC are 1. SAP R/3 system 2. XI system My question is which partner profile type i have select to send ID

  • Web Broadcasting Error

    Hello Experts, Our users cannot use the broadcasting function in Web reports to distribute reports by email.  They are getting the error message that they do not have the necessary authorizations (authorization object S_OC_SEND).  Where do I assign t

  • Web form taking too long to generate

    Hello I have a Data Form issue, My webform contains more than a 1000 CCenters in the page view. When selecting any of the CCenters the Data Form generates perfectly, all accept one of them!! Once a user selects that Center, it takes about 2.5 hours t

  • Why does Firefox run supper slow? Can u fix it to run faster on webstie

    every time i get on a website it never loads right running to slow it takes for every on the websites. on www.yahoo.com @ www.Face book.com @ www.tagged.com I have trouble with fire fox all the time on these website they run to freaking slow it sucks

  • Can't Install or update apps on iPod Touch 5g

    Hi, i am having a very serious problem with my iPod. it is an iPod Touch 5th Generation, 32GB, blue. It is currently running iOS 8.2. The problem is, I can't install or update any apps. It just sits on the home screen grayed out and saying "Waiting..