Using oracle sequence in SQL Loader

I'm using oracle sequence in control file of sql loader to load data from .csv file.
Controlfile:
LOAD DATA APPEND
INTO TABLE PHONE_LIST
FIELDS TERMINATED BY "," TRAILING NULLCOLS
PHONE_LIST_ID "seqId.NEXTVAL",
COUNTRY_CODE CHAR,
CITY_CODE CHAR,
BEGIN_RANGE CHAR,
END_RANGE CHAR ,
BLOCKED_FREE_FLAG CHAR
Datafile:
1516,8,9,9,B
1517,1,1,2,B
1518,8,9,9,B
1519,8,9,9,B
1520,8,9,9,B
1521,8,9,9,B
1) As first column uses oracle sequence, we have not defined that in datafile.
This gives me error "Can not insert NULL value for last column"
Is it mandatory to specify first column in datafile, even though we are using sequence?
2) Another table is referencing PHONE_LIST_ID column (the one for which we using sequence) of this table as a foreign key.
So is it possible to insert this column values in other table simultaneously? Sequence no. should be same as it is in first table...
Kindly reply this on urgent basis....

use BEFORE INSERT trigger
with
select your_seq.nextval into :new.id from dual;

Similar Messages

  • Error when using Oracle Migration WorkBench (Sql Server 2k to Oracle 8i)

    I'm trying to migrate a Sql Server 2k database to an Oracle 8i schema using OMWB. After using BCP to collect metadata information on the source database, I tried to capture the source data model and got a "Capture aborted" message on the progress screen (even though then it appears a dialog window reporting "0 errors and 0 warnings", funny!). Down there is the error log OMWB generated. After reading some posts, I changed some columns of the OMWB dictionary that holds the source database name, but still got the same error. If someone can enlighten me on this toppic, I'd greatly appreciated it.
    Here's the error log of OMWB:
    ** Oracle Migration Workbench
    ** Production
    ** ( Build 20050629 )
    ** OMWB_HOME: D:\Datos\Download\Oracle\Oracle Migration Workbench\omwb
    ** user language: es
    ** user region: null
    ** user timezone:
    ** file encoding: Cp1252
    ** java version: 1.4.2_04
    ** java vendor: Sun Microsystems Inc.
    ** o.s. arch: x86
    ** o.s. name: Windows 2000
    ** o.s. version: 5.0
    ** Classpath:
    ..\lib\boot.jar
    ** Started : Fri Feb 23 17:18:48 GMT-03:00 2007
    ** Workbench Repository : Oracle8i Enterprise Edition Release 8.1.6.0.0 - Production
    With the Partitioning option
    JServer Release 8.1.6.0.0 - Production
    Repository Connection URL: jdbc:oracle:thin:@ServerCms:1521:sigcewbc
    ** The following plugins are installed:
    ** Microsoft Access 2.0/95/97/2000/2002/2003 Plugin, Production Release 10.1.0.4.0
    ** Microsoft SQLServer 2000 Plugin, Production Release 10.1.0.4.0
    ** Microsoft SQLServer 6.5 Plugin, Production Release 10.1.0.4.0
    ** Microsoft SQLServer 7.0 Plugin, Production Release 10.1.0.4.0
    ** Active Plugin : SQLServer2K
    EXCEPTION :SQLServer2KDisconnSourceModelLoad.loadSourceModel(): oracle.mtg.migration.MigrationStopException: java.lang.IndexOutOfBoundsException: Index: 15, Size: 15
    ** Shutdown : Fri Feb 23 18:00:50 GMT-03:00 2007

    Duplicate thread
    Error when using Oracle Migration WorkBench (Sql Server 2k to Oracle 8i)

  • Using Sequence in SQL Loader

    Hi,
    Does anybody know if I can generate the unique primary key using an Oracle Sequence for a Database table to which I am inserting records in SQL Loader?
    I checked the SQL Loader manual and there is no information as to how to make use of a Oracle sequence.. in the control file?
    Thanks
    Surajit

    Yes, you can do it. Create the sequence (suppose you call it "PK_SEQ_X") and then in your control file reference it as "PK_SEQ_X.NEXTVAL". For example suppose you wanted to put it into a column named 'Y' the entry in your control file will look like 'load data insert into table Z (Y "PK_SEQ_X.NEXTVAL", ....)'
    Note that the double quotes around the sequence name are required.

  • Index is unusable after using Direct path of SQL Loader

    When using the Direct path of SQL Loader to load records from a comma(,) seperated file into a table, the index which I specify the records are sorted in becomes unusable. In the log file created by SQL Loader the error: "ORA-01409: NOSORT option may not be used; rows are not in ascending order" occurs. I am pre sorting the data in the order of the index, the index is a multi column index. The index and table prior to initiating SQL Loader are not empty and contain existing records.
    Can anybody suggest a reason as to why this is happening even thought I am pre sorting the data in ascending order as per the index?
    Brad.

    Thanks for reply Gerald!
    After further investigation I kind of answered my own question and found that the data I was loading was not in the order that Oracle was expecting. The problem stems from how the UNIX command SORT works compared to how data is ordered by in Oracle by the ORDER BY statement. I was using UNIX's SORT command to pre sort my data before loading it directly into Oracle.
    UNIX's SORT seems to order Null's before anything else in ascending order, where as Oracle's ORDER BY order's Null values last for ascending order!
    I got around this by putting in my pre-sorted data the highest printing ASCII character when ever a field was Null. The highest printing ASCII character is 'tilde' (~). As UNIX's SORT uses the ASCII collating sequence to determine the sort order the post-sorted data was sorted as per Oracle expected. And to not actually load up "~" into my Oracle table I just specified in the SQL*Loader control file for these fields, NULLIF (field_name = "~").

  • Oracle RAC and sql loader

    hi all,
    We have Oracle 10g RAC on IBM AIX
    Today i will be uploading data in a table through sql loader.
    I want that at the time of insertion only data which i am inserting goes into the table,As i am using sequence on particular column A.
    Problem is If i shutdown database then i will not to able to insert data and if i doesnt shutdown db value for that column A is generated automatically when application works.
    i have recommanded that we should stop connectivity of application with database then i will perform insertion but some people are saying no.Find other method
    What steps should i do?

    Ok i thing my question was not clear
    I have table XYZ
    A B C
    1 2 3
    4 4 5
    if application is connected to database value to Coulmn is incremented
    A B C
    1 2 3
    4 4 5
    5 6 7
    i have to insert into table XYZ using sql loader giving sequence (4,1) on column A.
    But if it is connected to application it will give me error of PK.
    as Value 5 is already inserted by application so how can i stop this.
    so that i can have the max value of coulmn and start sequence
    Hope this time make u clear.
    sorry for bad english

  • Using User function in SQL*Loader

    Hi, I have created the following control file. I am using DIRECT path insert. I am using a function to retrieve the column system_date. However, when I am running sql*loader, the fields system_date and load_date are loaded with null value.
    OPTIONS (ERRORS=999999999, DIRECT=TRUE, ROWS=100000, SKIP=1)
    LOAD DATA
    INFILE 'Z:\xx.csv'
    APPEND
    PRESERVE BLANKS
    INTO TABLE TB_RAW_DATA
    FIELDS TERMINATED BY ','
    OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    REFERENCE_NUMBER,     
    SYSTEM_DATE "pkg_ken_utility.Fn_ken_get_param_value('SYSTEM_DATE','SYSTEM_DATE')",
    LOAD_DATE "SYSDATE"
    )

    No,
    You can not call PL/SQL functions in DIRECT PATH mode, also this is documented, so you should not need to ask.
    Sybrand Bakker
    Senior Oracle DBA

  • Importing to a Oracle Table from SQL Loader Fails

    Hi ,
    When I try to upload one xml file from my server to my table in oracle server using sql loader it fails at times.Some times it works perfectly.
    This is a daily process which automatically dumps data to my oracle.
    Please find the error log :
    SQL*Loader: Release 10.2.0.4.0 - Production on Thu Dec 5 04:07:32 2013
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Control File:   xmlFeedDelta.ctl
    Data File:      xmlFileNames_Delta.txt
      Bad File:     xmlFileNames_Delta.bad
      Discard File:  none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 1000
    Bind array:     50000 rows, maximum of 256000 bytes
    Continuation:    none specified
    Path used:      Conventional
    Table XMLFEEDDELTA, loaded from every logical record.
    Insert option in effect for this table: APPEND
       Column Name                  Position   Len  Term Encl Datatype
    FILENAME                            FIRST  4000   ,       CHARACTER           
    FILECONTENT                       DERIVED     *  EOF      CHARACTER           
        Dynamic LOBFILE.  Filename in field FILENAME
    value used for ROWS parameter changed from 50000 to 63
    SQL*Loader-643: error executing INSERT statement for table XMLFEEDDELTA
    ORA-03113: end-of-file on communication channel
    SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
    Table XMLFEEDDELTA:
      0 Rows successfully loaded.
      0 Rows 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.
    Space allocated for bind array:                 252378 bytes(63 rows)
    Read   buffer bytes: 1048576
    Total logical records skipped:          0
    Total logical records read:             1
    Total logical records rejected:         0
    Total logical records discarded:        0
    Run began on Thu Dec 05 04:07:32 2013
    Run ended on Thu Dec 05 04:08:42 2013
    Elapsed time was:     00:01:10.05
    CPU time was:         00:00:00.28
    My Control File Looks like this :
    LOAD DATA
    INFILE xmlFileNames_Delta.txt
    INTO TABLE xmlFeedDelta APPEND
    fields terminated by ','
    filename CHAR(4000),
    filecontent LOBFILE(filename) terminated by eof
    My Database version :
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE 11.2.0.2.0 Production"
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    I am not sure why this is happening at times . Any help would be appreciated.

    Hi,
    have you tried with the FILLER  command like
    LOAD DATA
    INFILE xmlFileNames_Delta.txt
    INTO TABLE xmlFeedDelta APPEND
    fields terminated by ','
    filename  FILLER CHAR(4000),
    filecontent LOBFILE(filename) terminated by eof

  • How to use Conditional statements in SQL Loader control file

    Hi,
    I am using sql loader to load a flat file to the table. I am using control file for this purpose as show below:
    LOAD
    INTO TABLE store_shrink
    TRUNCATE
    FIELDS TERMINATED BY "     "
    TRAILING NULLCOLS
    SITE_ID char,
    ST_SHRINK char,
    ST_REVENUE char,
    SHRINK_PR char ":ST_SHRINK/:ST_REVENUE"
    My question is this. If in the flat file the value of 'ST_REVENUE' is '0', then I want 'SHRINK_PR' to be '0' as well, and skip the calculation (:st_shrink/:st_revenue).
    How to achieve this with the conditional statement or using any Oracle function?
    Any help or suggestion is greatly appreciated.
    Thanks in advance.

    Hi there,
    I tried the following in my above query and it doesn't work somehow. Anyone has an idea? I have been on internet throughout but to no avail. Please help:
    LOAD
    INTO TABLE store_shrink
    TRUNCATE
    FIELDS TERMINATED BY "     "
    TRAILING NULLCOLS
    SITE_ID char,
    ST_SHRINK char,
    ST_REVENUE char,
    SHRINK_PR char "case (when :st_revenue<>'0.00' then :SHRINK_PR=:ST_SHRINK/:ST_REVENUE else :SHRINK_PR='0.00') end"
    )

  • Use of WHEN in SQL Loader Control File

    Does anyone know of a way, using the CTL file below, to NOT LOAD (i.e. discard) any record where field G is null -OR- substr(G,1,3)='CON'+ (the first 3 characters of field G are "CON")?
    The WHEN clause seems very limited in what it can test and all my attempts to use a compound condition, much less the SUBSTR function, have failed. The documentation indicates that only very simple conditions can be specified.
    (Oracle 10g, Unix)
    Thanks
    LOAD DATA
    TRUNCATE
    INTO TABLE TEST_TABLE
    WHEN (G <> '')
    FIELDS TERMINATED BY "^"
    TRAILING NULLCOLS
    A ,
    B FILLER,
    C FILLER,
    D FILLER,
    E FILLER,
    F FILLER,
    G "LTRIM(:G,'0')",
    H FILLER,
    I FILLER,
    J FILLER,
    K SYSDATE,
    L CONSTANT "SQLLDR"
    )

    Hello MTM.
    The WHEN clause in SQL*Loader, despite what you might read, doesn't seem to evaluate the value of the column you specify after SQL clauses are processed. Therefore, the only way you can guarantee to NOT LOAD a record is by using a function to raise an application error when the column data meets your criteria. You'll need to do some basic comparisons between bad data and discarded data in the bad data file to isolate these.
    You can still discard the null data using (replace ne with greater and less than)WHEN (g ne '')Hope this helps,
    Luke
    Please mark the answer as helpful or answered if it is so. If not, provide additional details.
    Always try to provide create table and insert table statements to help the forum members help you better.

  • Using constant values in SQL Loader control file

    Hi,
    I have a requirement where I need to migrate the data of 6 tables from MS Access into Oracle data base. I have written SQL Loader scripts so that I can create CSV files based on MS Access data and then migrate into Oracle. But in Oracle tables we have 4 common columns like Create_By, Created_Date,Updated_By and Update_Date, and those fields should be taken care by system. So, basically system should update login user ID and sysdate values in respective columns. My question here is, I do not have above mentioned common columns in MS Access tables. So, can I hard code those values in control file by saying
    Created_By CONSTANT user,
    Create_Date CONSTANT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS'),
    Updated_By CONSTANT user,
    Updated_Date CONSTANT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS')
    Please let me know your valuable suggestions.

    You do it without it constant
    --sample data file
    1,2,,
    3,4,,
    LOAD DATA
    INFILE 'D:\d.csv'
    INTO TABLE ABC
    FIELDS TERMINATED BY ","
    ( A,
      B,
      C sysdate,
      D "USER"
    )Edited by: J99 on Jul 23, 2009 12:14 PM
    OR use to avoid extra ',' in datafile.
    --sample data file
    1,2
    3,4
    LOAD DATA
    INFILE 'D:\d.csv'
    INTO TABLE ABC
    FIELDS TERMINATED BY "," TRAILING NULLCOLS
    ( A,
      B,
      C sysdate,
      D "USER"
    )

  • HOW TO USE a sequence in merge load

    Hi,
    Someone can help me with a solution for loading a table with merge option and one of the column has values from a sequence.
    regards
    Babu

    Can we use a sequence to load a table with IKM Oracle Incremental Update (MERGE)?

  • Sequences in SQL*Loader

    Hi guys. I have a problem and can´t solve it.
    I am a few rookie in oracle.
    I have to load a txt file.
    I develope the next ctr:
    LOAD DATA
    INFILE './file.txt'
    INTO table
    REPLACE
    FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
    field_1,
    field_2,
    ID SEQUENCE(MAX,1)
    My problem is that new records would be:
    value1_field_1 value1_field_2 1
    value2_field_1 value2_field_2 2
    value3_field_1 value3_field_2 3
    value4_field_1 value4_field_2 4
    value5_field_1 value5_field_2 5
    In the next load, I would have the next;
    value1_field_1 value1_field_2 1
    value2_field_1 value2_field_2 2
    value3_field_1 value3_field_2 3
    value4_field_1 value4_field_2 4
    value5_field_1 value5_field_2 5
    value6_field_1 value6_field_2 6
    value7_field_1 value7_field_2 7
    value8_field_1 value8_field_2 8
    value9_field_1 value9_field_2 9
    value10_field_1 value10_field_2 10
    Well( Ii write too much, :-) ), my problem is that i want the following in the first load:
    value1_field_1 value1_field_2 1
    value2_field_1 value2_field_2 1
    value3_field_1 value3_field_2 1
    value4_field_1 value4_field_2 1
    value5_field_1 value5_field_2 1
    And after second load:
    value1_field_1 value1_field_2 1
    value2_field_1 value2_field_2 1
    value3_field_1 value3_field_2 1
    value4_field_1 value4_field_2 1
    value5_field_1 value5_field_2 1
    value6_field_1 value6_field_2 2
    value7_field_1 value7_field_2 2
    value8_field_1 value8_field_2 2
    value9_field_1 value9_field_2 2
    value10_field_1 value10_field_2 2
    It seems easy, but i don't know how make it. Can someone help me, please?.
    Regards, Javi.
    (Now i haven't primary key in the table: I don't have problems with same IDs)
    Edited by: user12249099 on 07-dic-2009 9:38
    Edited by: user12249099 on 07-dic-2009 9:38
    Edited by: user12249099 on 07-dic-2009 9:39

    Hi,
    field_1,
    field_2,
    ID SEQUENCE(MAX,1)
    )In this code, dont use the sequence. Instead have a variable and increment it after every load.
    Edited by: machan on Dec 7, 2009 11:01 AM
    Edited by: machan on Dec 7, 2009 1:03 PM

  • Oracle Replication and SQL*Load direct Path

    We are setting up Oracle replication and have a few tables which are loaded using SQL*Loader Direct path. I have following questions:
    1. Can MultiMaster replication replicate direct patch sqlloaded data.
    2. If the answer to the above question is no, should we set up a new snapshot replication group . All other tables are in the Multi Master replication.
    3. Another question is on the number of replication groups. How many of these we should create. We have total of about 500 tables and database size is about 450 Gig. We plan to replicate all the tables and the refresh interval we want to be one minute for all the tables. Does having more/less replication groups help??
    Thanks for your help

    We are setting up Oracle replication and have a few tables which are loaded using SQL*Loader Direct path. I have following questions:
    1. Can MultiMaster replication replicate direct patch sqlloaded data.Yes, I don't think it should matter how the table is getting updated.
    2. If the answer to the above question is no, should we set up a new snapshot replication group . All other tables are in the Multi Master replication.see above
    3. Another question is on the number of replication groups. How many of these we should create. We have total of about 500 tables and database size is about 450 Gig. We plan to replicate all the tables and the refresh interval we want to be one minute for all the tables. Does having more/less replication groups help??
    Thanks for your help I believe what Oracle recommends is that you split up your tables into replication groups transactionally. I personally have 6 replication groups supporting 700+ tables. They are broken up more by business function than by number and size.

  • How to use nvl() function in SQL Loader

    I am trying to use nvl() funtion in my SQL Loader control file and I keep geting errors. Would someone please tell me where I can find the syntax reference to this?
    Thanks a lot!

    I just answered a similar question like this last Thursday.
    SQL*LOADER how to load blanks when data is null

  • Using Oracle Sequence

    I am using sequence to generate Id in table. I need the generated value in program to inster that value in another table.
    right now i am selecting value from "select <seq>.nextval from dual"
    is this right way or there is other better way of doing this?

    sorry, I did not mention I am doing this in MDB and Application server maintains a pool of MDB's so multiple MDB's will be accessing the sequence object so will curval return right value to me?
    That is one correct way to use a sequence. Note that
    you can also do the following:
    INSERT INTO PARENT (ID, ...) VALUES
    (<seq>.nextval, ...);
    INSERT INTO CHILD (PARENT_ID, NUM, ...) VALUES
    (<seq>.currval, 1, ...);
    INSERT INTO CHILD (PARENT_ID, NUM, ...) VALUES
    (<seq>.currval, 2, ...);<seq>.currval returns the last generated sequence
    number for the session. See
    http://download-west.oracle.com/docs/cd/B14117_01/serve
    .101/b10759/pseudocolumns002.htm for more info.

Maybe you are looking for

  • I have a problem, I need some help.

    So, tonight I decided to update my iPod, the new iOS 4.2.1 (which is as high as my iTouch allows me to go) was looking pretty good by now. So I did. But once my comp. was done updating both my computer software for itunes + my ipod, I required me to

  • What's the alternative to losing everything?

    Guys I can't believe we lose all these features in iCloud, http://support.apple.com/kb/HT4898 – what is the alternative? Surely Mac would have one? I run 4 computers and need keychains, system preferences, signatures to all be in sync with each other

  • Query regarding MM Consignment Recon Report

    Hi,    We have to develop a report in which one of the requirements is to provide the info records and its consumption price along with sap settled amount to be displayed The info price(KBETR type konp- KBETR) we have retrieved from KNOP table based

  • Fill Image not visible with iOS (ipad/iphone)

    Hi I created a website with Adobe Muse and I have an issue when surfing with ipad or iphone. When you have a coloured rectangle and add a fill image to it, it's perfectly visible with any type of browser on a desktop pc. Yet, when using iOS7 the imag

  • Dynamic Table display Horizontally??

    Is there any relatively easy way to make a DW CS3 Dynamic Table display horizontally? So far the best I can figure out is to do multiple <cfoutput query= lines per: <table border="1"> <tr> <cfoutput query="rsOfficeStyles" startRow="#StartRow_rsOffice