Load multiple records in 1 table from 1 line in text file w/sql loader

hi guys,
quick question, perhaps someone can help. searched around and didn't see this question asked before, and can't find any answer in SQL Loader faqs or docs.
i know i can extract multiple logical records from a single physical record in the input file as two logical records, and then use two into tables clauses to load the data into the table. see oracle 9i sql loader control file reference chapter 5 to see what i am talking about.
but my question follows:
cust_id amount1_val amount1_qual amount2_val amount2_qual amount3_val amount3_qual
123 1500.35 TA 230.34 VZ 3045.50 TW
basically i want to use one sql loader statement to load these 3 records into 1 table. the issue for me is that i need to re-use the cust_id for all 3 records as the key, along with the qualifier code. the example in the Oracle docs only works for data where the logical records are completely separate -- no shared column values.
i'm sure this is possible, perhaps using some :cust_id type parameter for the 2nd and 3rd records, or something, but i just don't have enough knowledge/experience with sql loader to know what to do. appreciate any help.
wayne

Hi wayne,
I found an example on what exactly you were looking for from an SQL*Loader documentation. Please see if it of some help to you
EXAMPLE
The control file is ULCASE5.CTL.
1234 BAKER 10 9999 101
1234 JOKER 10 9999 777
2664 YOUNG 20 2893 425
5321 OTOOLE 10 9999 321
2134 FARMER 20 4555 236
2414 LITTLE 20 5634 236
6542 LEE 10 4532 102
2849 EDDS xx 4555
4532 PERKINS 10 9999 40
1244 HUNT 11 3452 665
123 DOOLITTLE 12 9940
1453 MACDONALD 25 5532
In the above datafile
Column1 - Empno
Column2 - ENAME
Column3 - Depno.
Column4 - MGR
Column5 - Proj no.
-- Loads EMP records from first 23 characters
-- Creates and loads PROJ records for each PROJNO listed
-- for each employee
LOAD DATA
INFILE 'ulcase5.dat'
BADFILE 'ulcase5.bad'
DISCARDFILE 'ulcase5.dsc'
1) REPLACE
2) INTO TABLE emp
(empno POSITION(1:4) INTEGER EXTERNAL,
ename POSITION(6:15) CHAR,
deptno POSITION(17:18) CHAR,
mgr POSITION(20:23) INTEGER EXTERNAL)
2) INTO TABLE proj
(empno POSITION(1:4) INTEGER EXTERNAL,
3) projno POSITION(25:27) INTEGER EXTERNAL) -- 1st proj
Notes:
REPLACE specifies that if there is data in the tables to be loaded (EMP and PROJ), SQL*loader should delete the data before loading new rows.
Multiple INTO clauses load two tables, EMP and PROJ. The same set of records is processed three times, using different combinations of columns each time to load table PROJ.
Regards,
Murali Mohan

Similar Messages

  • Loading from text file using Sql Loader

    I need to load data from a text file into Oracle table. The file has long strings of text in the following format:
    12342||||||Lots and lots of text with all kinds of characters including
    ^&*!#%#^@ etc.xxxxxxxxxxxxxxxxxxxxxxx
    yyyyyyyyyyyyyyyyyyyyyyyyytrrrrrrrrrrrrrrrrrrr
    uuuuuuuuuuuuuuuuuuurtgggggggggggggggg.||||||||
    45356|||||||||||again lots and lots of text.uuuuuudccccccccccccccccccccd
    gyhjjjjjjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkklllllllllllnmmmmmmmmmmmmnaaa|||||||.
    There are pipes within the text as well. On the above example, the line starting with 12342 is an entire record that needs to be loaded into a CLOB column. The next record would be the 45356 one. Therefore, all records have a bunch of pipes at the end, so the only way to know where a new record starts is to see where the next number is after all the ending pipes. The only other thing I know is that there are a fixed number of pipes in each record.
    Does anyone have any ideas on how I can load the data into the table either using sql loader or any other utility? Any input would be greatly appreciated. Thanks.

    STFF [url http://forums.oracle.com/forums/thread.jspa?messageID=1773678&#1764219]Sqlldr processing of records with embedded newline and delimiter

  • New Line in data file for sql loader

    Hi all,
    I have a requirement to load a data file in which some of the rows are in new line as given in following example. If i put a '\n' character in control file, then it will load only those records which have newline in them ignoring non new line ones. please have a look at control fileand provide a solution to it :-
    32 grand street ~NY~NY
    42 riverdrive,
    apt 1B ~PL~TX
    Richardson road
    apt 32~ SF ~CA
    As you see there are newline characters in record 2 and 3, right now my control file looks like this -
    LOAD DATA
    INFILE 'example.txt' "STR '\r\n'"
    INTO TABLE "temp_table"
    INSERT
    FIELDS TERMINATED BY '~'
    TRAILING NULLCOLS
    (ADDRESS1,
    CITY,
    STATE)
    If i remove "STR '\r\n'" , then the data gets loaded into different rows like the third record looks like this -
    ADDRESS                         CITY                     STATE
    Richardson road null null
    apt 32 SF CA
    Please help.

    Your requirement is very unclear.
    Is this your INPUT ?
    --record 1
    32 grand street ~NY~NY
    --record 2
    42 riverdrive, --"NL"
    apt 1B ~PL~TX
    --record 3
    Richardson road --"NL"
    apt 32~ SF ~CAIs this your OUTPUT?
    ADDRESS      CITY STATE
    32 grand street NY   NY
    42 riverdrive,     null null
    apt 1B          PL   TX
    Richardson road null null
    apt 32           SF   CAAre you using Linux or Windows platform?
    You should have only one record terminator character.
    *\r\n* is Windows The End of Line character (The Carriage Return + The Line Feed).
    "STR '\r\n'" = "str X'0D0A'"
    If there is no data after \r\n, columns will be null.
    http://docs.oracle.com/cd/B28359_01/server.111/b28319/ldr_concepts.htm#i1005800

  • How to skip the first row in Text file (in Sql Loader)

    Hi All,
    How to say the control file to skip the first row of the text file..
    i just going this example
    this is my text file:
    01308201222455038130820122245503813082012224550382
    1090358 474661834012245503813082012 0075 0 00000000000 000000000 00000130820120000000000000000 136.84 -833.3911082012 000000 000 009035847466183 090358 47466183 0015007514300000970001430000097700BH1150274792012081320120811201208122012-08-11-22.45.50.38369899999.0075LIQJGL17
    Control file:
    OPTIONS
    DIRECT = TRUE ,
    PARALLEL = FALSE ,
    SKIP = 1,
    ERRORS = 0
    UNRECOVERABLE
    LOAD DATA
    INFILE      <"FILE_DIR">
    BADFILE <"FILE_DIR">
    INSERT
    INTO TABLE DAILY_TRANSACTION
    WHEN (1:1)='D'
    TRAILING NULLCOLS
    Above the Eaxmple text file i need to Skip the first row which is
    01308201222455038130820122245503813082012224550382
    please can anyone suggest me is this correct?
    if not please correct me please
    since two days i been serching but i didn't get any thing
    Thank's
    Edited by: Lavanya on 24-Sep-2012 00:51

    Lavanya wrote:
    Hi Jeneesh,
    Thank you for your prompt replay
    I didn't try to load this control file
    And i need one more question
    I have Text file in my Machine which Contains very huge data so i was wrote one control file for that, and i got FTP connection also as well as.
    My question is firstly I need to PUT the Text file Into Unix Server isn't?
    so when i trying to put the text file into unix it's giving an error
    ftp>put c:/abc.txt
    Not connectedYou haven't succesfully made your FTP connection to the server.
    e.g.
    c:\>ftp
    ftp> o testserver
    Connected to testserver.mycompany.com.
    220 testserver FTP server ready.
    User (testserver.mycompany.com:(none)): myuser
    331 Password required for myuser.
    Password:
    230 User myuser logged in.
    ftp>then you can use FTP to put your data to the server. Remember, if you are transferring a text file from a windows based operating system to a unix server you need to put it in ASCII mode...
    ftp> ascii
    200 Type set to A.
    ftp>which will automatically convert the windows CR/LF pairs to the single LF character used by unix.

  • To load multiple records in multiple target tables

    I have to read multiple records as a set from a single source flat file and load into different target tables.
    I have to read 3 records as a set and load into 3 different target tables and read another 3 records as a set and load into previous 3 target tables and it goes on
    till all the records from the flat file are loaded.
    The structure of the file is as follows:
    Header Record
    Line Record
    Distribution Record
    Header Record
    Line Record
    Distribution Record
    Read Header Record and load into target table A
    Read Line Record and load into target table B
    Read Distribution Record and load into target table C
    --- repeat the same steps till all records are read and loaded into target tables.
    I would appreciate if anyone can suggest the best approach of designing interface/package and error conditions to handle ?
    Thanks,
    Ram

    Hi,
    in this case you must create datastore under a 'Flat file' model
    Create for example 3 datastore with the same ressource (file) but change defintion of column
    Generaly on the first column, define the 'pattern' for each specific format 'variable code'
    You must create 3 interfaces and load your target (databse table for example)
    Regards
    Stephane

  • Insert multiple records into a table(Oracle 9i) from a single PHP statement

    How can I insert multiple records into a table(Oracle 9i) from a single PHP statement?
    From what all I've found, the statement below would work if I were using MySQL:
         insert into scen
         (indx,share,expire,pitch,curve,surface,call)
         values
         (81202, 28, 171, .27, 0, 0, 'C' ),
         (81204, 28, 501, .25, 0, 0, 'C' ),
         (81203, 17, 35, .222, 0, 0, 'C' ),
         (81202, 28, 171, .27, 2, 0, 'C' ),
         (81204, 28, 501, .20, 0, 1, 'C' ),
         (81203, 28, 135, .22, 1, 0, 'C' )
    The amount of records varies into the multiple-dozens. My aim is to utilize the power of Oracle while avoiding the i/o of dozens of single-record inserts.
    Thank you,
    Will

    You could look at the INSERT ALL statement found in the documentation here:
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_913a.htm#2133161
    My personal opinion is that you probably won't see any benefit because under the hood I think Oracle will still be doing single row inserts. I could be wrong though.
    The only way to confirm was if you did a test of multiple inserts vs an INSERT ALL, that is if the INSERT ALL met your requirements.
    HTH.

  • Multiple record update in TABLE Control.

    Hi All,
    I m developing dialog program with table control.
    I want to know how to update multiple records through the table control if user selects more than one.
    Also depending on some condition i want to change the status of one reocrd and not the column as a display field and won't be editable. I have tried with loop at screen and modify screen, but it is showing the whole column as display only.
    ANy solution let me know

    Hi,
    pls chk this standard pgms.
    for examples on table control
    demo_dynpro_tabcont_loop
    demo_dynpro_tabcont_loop_at
    RSDEMO_TABLE_CONTROL
    chk a sample code.
    DATA :BEGIN OF int_table OCCURS 0,
           fld1 TYPE ztable-fld1,
            fld2 TYPE ztable-fld2,
            fld3 TYPE ztable-fld3,
            chk(1),
          END OF int_factor.
    *write the blow code in PAI
    LOOP AT int_table WHERE chk = 'X'.
    *modify the data base table
    MODIFY ztable FROM  int_table. "from header
    clear int_table
    ENDLOOP.
    regards
    Anver

  • Inserting Multiple Records into two table

    I want to insert records from a ADF swing form into two tables. In the first table the primary key is generated by a trigger and then I need to retrieve the primary id generated and then insert multiple records in another table using the primarykey obtained from the first table as foreign key.
    How to do this ?

    User,
    If you're using ADF Business components, have a read on the DBSequence data type. If you have two VO's linked by a view link, and the FK is a DBSequence type, all this happens for you out-of-the-box.
    Hope this helps,
    john

  • Delete the records in a table from forms

    Oracle forms6i
    Hai All
    I am using forms6i and my need is i have generated a forms and the output is viewed through tables and i need to to delete all the records in the table from my forms while executing next time pls tell me
    Regards
    Srikkanth.M

    hi
    please try something like this.
    Begin
    Delete From Master_Tbl Cascade;
    forms_ddl('Commit');
    End;sarah

  • Extract tables from "Oracle Apss 11.0.3" and load it to "Oracle Apps 11i"

    Hi hussein,
    I am tasked to extract the following tables from Oracle Apps 11.0.3 and load it to Oracle Apps 11.5.10.2.
    PO_VENDORS
    PO_VENDOR_SITES_ALL
    Can I use export / import?
    Thanks a lot

    Hi,
    I believe export/import of individual apps tables is not supported due to objects dependency and refrential integrity.
    Regards,
    Hussein

  • How to insert new record into oracle table from GridView in VS2005.

    I need to insert records into Oracle10g table from VS2005 GridView using the Insert Method in Business Logic Class. The Update and Delete Methods are working fine. What's the best way out?

    How is it "not possible"?
    Either modify the Class for the new fields, or give the new fields default values (if applicable). If the type of an existing column has changed, then only the first option is available.
    Where's the problem?

  • Insert Data into Table from TXT or CSV file !!!!!

    Dear All,
    Recently I have started working on APEX. In Oracle Forms, we used to use TEXT_IO for inserting records into tables from txt files. Now I want to do the same thing in apex 3.2. How can I insert data into tables from txt of csv files.
    Waiting of your valuable suggestions.
    With kind regards,
    Yousuf.

    Yousuf
    wwv_flow_files is used by APEX to hold uploaded files.
    If you incorporate a file browse item on you page, browse for the selected file, then submit the page (having the PL/SQL process described as an on suibmit process) then what I detailed should work.
    If you don't need users to have access to this then just go to Home>Utilities>Data Load/Unload in APEX and there is a handy load utility there that does it all for you.
    Cheers
    Ben

  • How to move the data of a table from sqlplus to XML file

    Hi,
    Could you pls guide me how to move the data of a table from sqlplus to XML file.
    i want to do it from sqlplus rather than toad.pls help
    Thanks

    Oh..I'm in 9i.
    Try this out..and let me know.
    DECLARE
    CTX DBMS_XMLGEN.CTXHANDLE ;
    XML CLOB ;
    F UTL_FILE.FILE_TYPE;
    XMLC VARCHAR2(32767);
    BEGIN
    CTX := DBMS_XMLGEN.NEWCONTEXT('SELECT * FROM department1 ') ;
    XML := DBMS_XMLGEN.GETXML(CTX) ;
    XMLC:=TO_CHAR(XML);
    SHOW_ENVELOPE(XMLC);
    F := UTL_FILE.FOPEN('ATTACH_FILES','DEPT.XML', 'W');
    UTL_FILE.PUT_LINE(F,XML);
    UTL_FILE.FCLOSE(F);
    END ;
    Good luck!!!
    Bhagat
    null                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Not loading from flat file using SQL*Loader

    Hi,
    I am trying to load from an excel file.
    first i converted excel file into csv file and save it as as dat file.
    in the excel file one column is salary and the data is like $100,000
    while converting xls to csv the salary is changed to "$100,000 " (with quotes and a space after the amount)
    after the last digit it will put a space.
    in the control file of sql*loader i had given
    salary "to_number('L999,999')"
    my problem is the space after the salary in the dat file.---> "$100,000 "
    what changes i have to make in the to_number function which is in the control file.
    Please guide me.
    Thanks & Regards
    Salih KM
    Message was edited by:
    kmsalih

    Thanks a lot Jens Petersen
    It's is loading ..........
    MI means miniute.
    am i correct.
    but i didn't get the logic behind that.
    can u please explain that.
    Thanks & Regards
    Salih KM

  • Upload Multiple files in SQL * Loader in one session

    Dear all,
    I want to upload multiple files using SQL*Loader in one go. In Unix its very easy as I have a quite experience of that. Could any body tell what is a way in Windows to upload multiple files in one go while using SQL * Loader. I want to run that using DOS's Batch file.
    Thanks
    Ghulam

    In Unix its very easy like we are putting $ sign.
    sqlldr userid=?????/?????
    control="/u12/cad_delta.ctl",log="/u12/full_extract/$1",data="/u12/$1",bad="/u12//full_extract/$1",errors=500,silent=feedback
    Suggest for Windows? It should read all .DAT files of the Windows Folder.
    Thanks

Maybe you are looking for