SqlLoader: how to create multiple records out of one CSV input line?

A question concerning the SQL-Loader.
I need to load data from a CSV file where one of the CSV values determines how many records should be inserted.
Example of the input data:
KEYWORD;2;REC1_COL1_X,REC1_COL2_X;REC2_COL1_X;REC2_COL2_X
KEYWORD;3;REC1_COL1_Y;REC1_COL2_Y,REC2_COL1_Y;REC2_COL2_Y;REC3_COL1_Y;REC3_COL2_Y
KEYWORD;4;REC1_COL1_Z;REC1_COL2_Z,REC2_COL1_Z;REC2_COL2_Z;REC3_COL1_Z;REC3_COL2_Z,REC4_COL1_Z;REC4_COL2_Z
If the KEYWORD is found, then the next value determines how many value pairs will follow, and therefore how many rows should be created in the affected DB table.
As a result I hope to achieve this:
SELECT Column1, Column2 FROM testTable
REC1_COL1_X,REC1_COL2_X
REC2_COL1_X;REC2_COL2_X
REC1_COL1_Y;REC1_COL2_Y
REC2_COL1_Y;REC2_COL2_Y
REC3_COL1_Y;REC3_COL2_Y
REC1_COL1_Z;REC1_COL2_Z
REC2_COL1_Z;REC2_COL2_Z
REC3_COL1_Z;REC3_COL2_Z
REC4_COL1_Z;REC4_COL2_Z
I learned how to import data using Oracle SQL loader for cases where one input line more or less matches a (new) row in a DB table. But how to handle this?

Hello 784948.
Assuming that the delimiter is a comma, and also assuming that the number of pairs is limited to four, you could use the following tested control fileLOAD DATA
APPEND
INTO TABLE testTable
WHEN (1:7) = 'KEYWORD' AND (9) = '1'
FIELDS TERMINATED BY ","
TRAILING NULLCOLS
( KeywordColumn    FILLER
, PairCountColumn  FILLER
, InputColumn1
, InputColumn2
, FillerColumn1    FILLER
, FillerColumn2    FILLER
, FillerColumn3    FILLER
, FillerColumn4    FILLER
, FillerColumn5    FILLER
, FillerColumn6    FILLER
INTO TABLE testTable
WHEN (1:7) = 'KEYWORD' AND (9) = '2'
FIELDS TERMINATED BY ","
TRAILING NULLCOLS
( KeywordColumn    FILLER  POSITION(1)
, PairCountColumn  FILLER
, InputColumn1
, InputColumn2
, FillerColumn1    FILLER
, FillerColumn2    FILLER
, FillerColumn3    FILLER
, FillerColumn4    FILLER
, FillerColumn5    FILLER
, FillerColumn6    FILLER
INTO TABLE testTable
WHEN (1:7) = 'KEYWORD' AND (9) = '3'
FIELDS TERMINATED BY ","
TRAILING NULLCOLS
( KeywordColumn    FILLER  POSITION(1)
, PairCountColumn  FILLER
, InputColumn1
, InputColumn2
, FillerColumn1    FILLER
, FillerColumn2    FILLER
, FillerColumn3    FILLER
, FillerColumn4    FILLER
, FillerColumn5    FILLER
, FillerColumn6    FILLER
INTO TABLE testTable
WHEN (1:7) = 'KEYWORD' AND (9) = '2'
FIELDS TERMINATED BY ","
TRAILING NULLCOLS
( KeywordColumn    FILLER  POSITION(1)
, PairCountColumn  FILLER
, FillerColumn1    FILLER
, FillerColumn2    FILLER
, InputColumn1
, InputColumn2
, FillerColumn3    FILLER
, FillerColumn4    FILLER
, FillerColumn5    FILLER
, FillerColumn6    FILLER
INTO TABLE testTable
WHEN (1:7) = 'KEYWORD' AND (9) = '3'
FIELDS TERMINATED BY ","
TRAILING NULLCOLS
( KeywordColumn    FILLER  POSITION(1)
, PairCountColumn  FILLER
, FillerColumn1    FILLER
, FillerColumn2    FILLER
, InputColumn1
, InputColumn2
, FillerColumn3    FILLER
, FillerColumn4    FILLER
, FillerColumn5    FILLER
, FillerColumn6    FILLER
INTO TABLE testTable
WHEN (1:7) = 'KEYWORD' AND (9) = '4'
FIELDS TERMINATED BY ","
TRAILING NULLCOLS
( KeywordColumn    FILLER  POSITION(1)
, PairCountColumn  FILLER
, FillerColumn1    FILLER
, FillerColumn2    FILLER
, InputColumn1
, InputColumn2
, FillerColumn3    FILLER
, FillerColumn4    FILLER
, FillerColumn5    FILLER
, FillerColumn6    FILLER
INTO TABLE testTable
WHEN (1:7) = 'KEYWORD' AND (9) = '3'
FIELDS TERMINATED BY ","
TRAILING NULLCOLS
( KeywordColumn    FILLER  POSITION(1)
, PairCountColumn  FILLER
, FillerColumn1    FILLER
, FillerColumn2    FILLER
, FillerColumn3    FILLER
, FillerColumn4    FILLER
, InputColumn1
, InputColumn2
, FillerColumn5    FILLER
, FillerColumn6    FILLER
INTO TABLE testTable
WHEN (1:7) = 'KEYWORD' AND (9) = '4'
FIELDS TERMINATED BY ","
TRAILING NULLCOLS
( KeywordColumn    FILLER  POSITION(1)
, PairCountColumn  FILLER
, FillerColumn1    FILLER
, FillerColumn2    FILLER
, FillerColumn3    FILLER
, FillerColumn4    FILLER
, InputColumn1
, InputColumn2
, FillerColumn5    FILLER
, FillerColumn6    FILLER
INTO TABLE testTable
WHEN (1:7) = 'KEYWORD' AND (9) = '4'
FIELDS TERMINATED BY ","
TRAILING NULLCOLS
( KeywordColumn    FILLER  POSITION(1)
, PairCountColumn  FILLER
, FillerColumn1    FILLER
, FillerColumn2    FILLER
, FillerColumn3    FILLER
, FillerColumn4    FILLER
, FillerColumn5    FILLER
, FillerColumn6    FILLER
, InputColumn1
, InputColumn2
)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.
Edited by: Luke Mackey on Aug 5, 2010 1:23 PM (always better to test before posting)

Similar Messages

  • How to create multiple records using ADF

    Currently working on my first ADF BC and UIX project, and I basically want to create multiple records after a user makes a choice on the screen. I would like to know at what layer should this functionality be implemented?
    Would this be more at the Struts/Controller level, where I have a java class to perform the creation as part of a data action? I ask because, I am not sure if this is feasible at the ADF BC level (View objects and Entity Objects) via some sort of customization, and i am new to the different possibilies avail as part of the ADF framework
    Regards
    Anora
    (Jdeveloper 10.1.2.1 build 1913, Oracle DB 10.1.2)

    I'd put it into the application module. You then can call the method from the controller layer or from an other application module. This way you put it into the business logic, which helps if you ever decide to use a different client approach (like swing).

  • Creating multiple shapes out of one image

    Hi!
    I tried several times now, but I just cant seem to get it. I have an image of person, with which I want to crop that person out of the background with the bezier tool. But I need to create multiple shapes to cover some background f.x under his arms. How can I do this?

    You realize I cannot see your screen, right? I do not understand your use of the terms "crop out" and "cover…under hsi arms." If you remove him, how are his arms still in the shot?
    Do you need multiple masks on one layer or do you need a different mask for every frame of video? That is called rotoscoping and is easily researched.
    bogiesan

  • How to create Multiple Region In to One Region

    hi
    How to create Morw then one into one Region.
    Thanks
    Manoj
    Edited by: Manoj Kaushik on Jan 4, 2010 6:08 AM

    Hi,
    this can be done in Apex 4.0 but in previous Releases i think it is not possible so far i know.
    MDK.

  • How to create multiple accouting documents for one invoice for diff curr

    Hi experts/gurus,
    I have a requirement where we need to create two two different accounting documents for one invoice. The scenario is this:
    1) We are exporting goods to oversea customer, as such the currency is bill in USD
    2) We also have transportation charges using another condition type, we need to capture this charges/accrual in local currency which is MYR.
    Currently, the system will automatically convert the transporation charges to USD when we create the invoice and the accounting document will be generated in USD for both sales and transport charges.
    is there a way to fullfil the above requirement, any setting in condition type or any user exists we can used to create hte accounting documents.
    Any ideas/input is highly appreciated, points will be awarded

    Hi Wan,
       The following user exits are available in report SAPLV60B for transfer to accounting (function group V60B): So please go through these.
    ·EXIT_SAPLV60B_001: Change the header data in the structure acchd
    You can use this exit to influence the header information of the accounting document. For example, you can change the business transaction, "created on" date and time, the name of the person who created it or the transaction with which the document was created.
    ·EXIT_SAPLV60B_002: Change the customer line ACCIT
    You can use this exit to change the customer line in the accounting document. This exit is processed once the ACCIT structure is filled in with data from document header VBRK.
    ·EXIT_SAPLV60B_003: Change the customer line in costing
    The customer line is filled in differently for costing. You can use exit 003 to influence the ACCIT structure.
    ·EXIT_SAPLV60B_004: Change a GL account item ACCIT You can add information to a GL account item (such as quantity specifications) with this exit.
    ·EXIT_SAPLV60B_005: User exit for accruals
    Once all relevant data for accruals was entered in the GL account item, you can add to this data with this exit.
    ·EXIT_SAPLV60B_006: Change the control line ACCIT
    You can use exit 006 to add information to the control line.
    ·EXIT_SAPLV60B_007: Change the installment plan
    You can use exit 007 to add information to the installment plan
    parameters in the GL account item.
    ·EXIT_SAPLV60B_008: Change the transfer structure ACCCR, ACCIT and ACCHD
    After the accounting document is filled in with data, you can use exit 008 to change the document once again.
    ·EXIT_SAPLV60B_010: Item table for customer lines
    You can use exit 10 to influence the contents of customer lines before they are created.
    ·EXIT_SAPLV60B_0011: Change the parameter for cash account determination or reconciliation account determination
    You can use this exit to change inbound parameters in order to influence account determination.
    I hope any one of these will solve your problem
    Thanks,
    Murali.

  • HOW TO CREATE MULTIPLE RECORDS IN A NONE DATABASE BLOCK?

    I have a Form where I have a none database block with unbound items. The block
    has 10 records. In the when-new-block instance I run a query by which I would
    like to fill up the block with data. The code fragment looks like the
    following:
    begin
    declare
    tmp_curr_rec_id number;
    begin
    -- a hibak kiolvasasa
    for c_hibak in ( select h.*, h.rowid
    from hibak h
    where 1=1 -- WF - Ide kerul a szurofeltetel
    order by bejelentes_datum asc
    ) loop
    -- bemasoljuk az adatokat az unbound item-ekbe
    :mc_adat.ub_azonosito := c_hibak.azonosito;
    :mc_adat.ub_verzio_letrehozas_datum :=
    c_hibak.verzio_letrehozas_datum;
    :mc_adat.ub_bejelento := c_hibak.bejelento;
    :mc_adat.ub_bejelentes_datum := c_hibak.bejelentes_datum;
    :mc_adat.ub_wf_verzio_csomopont :=
    c_hibak.wf_verzio_csomopont;
    :mc_adat.ub_wf_utolso_esemeny_szoveg :=
    c_hibak.wf_utolso_esemeny_szoveg;
    :mc_adat.ub_hiba_leiras := c_hibak.hiba_leiras;
    :mc_adat.ub_hiba_hely := c_hibak.hiba_hely;
    :mc_adat.ub_rekord_jelleg := 'H';
    :mc_adat.ub_rowid := c_hibak.rowid;
    -- beallitjuk a rekordot-ot olyanra, mintha semmi nem valtozott
    volna
    -- nem szeretnenk a form bezaraskor mindenfele figyelmezteteseket
    -- olvasni a kepernyon
    tmp_curr_rec_id := get_block_property( :system.current_block,
    current_record );
    set_record_property( tmp_curr_rec_id, :system.current_block,
    status, new_status );
    create_record;
    end loop;
    end;
    end;
    The block's update allowed, insert allowed, delete allowed property is set to
    true.
    The result of the code above is that only the last record fetched shows up in
    the block. The problem is - as I found out - is that aech record is fetched,
    the values are copied to the block items, but the create_record built-in
    command would not move the cursor to the next row.
    Can some one please help me with this?
    TIA,
    Tamas Szecsy

    The problem was with the following code segment:
    tmp_curr_rec_id := get_block_property( :system.current_block, current_record );
    set_record_property( tmp_curr_rec_id, :system.current_block, status, new_status );
    After omitting these two lines, the code worked properly.
    Thansk for all whoe replied.
    Regards,
    Tamas

  • How to Create Multiple Sources/Classes with one Script

    I am trying to get all of my java sources, or classes, into one script so that I can move them all to another server without having to compile each file individually. When I concatenate two files and try to compile I get an ORA-29536: badly formed source error.
    How can I get multiple definitions into one file and compile all of the classes?
    Thanks,
    Gregory

    Gregory:
    If you want to upload several Java classes in one script the solution is .sql file, for example:
    set define ?
    create or replace and compile java source named "my.Sleep" as
    package my;
    import java.lang.Thread;
    public class Sleep {
    public static void main(String []args) throws java.lang.InterruptedException {
    if (args != null && args.length>0) {
    int s = Integer.parseInt(args[0]);
    Thread.sleep(s*1000);
    } else
    Thread.sleep(1000);
    create or replace and compile java source named "my.App" as
    package my;
    public class App {
    public static void main(String []args) throws java.lang.InterruptedException {
    System.out.println(args[0]);
    exit
    Then the .sql file can be parsed using the SQLPlus, JDeveloper or SQLDeveloper tools.
    HTH, Marcelo.

  • How to create separate articles out of one InDesign document?

    I have a pre-created InDesign 5 document that is about 50 pages. There are different articles within these pages, and there are different sections created for the page numbers. When I add to the folio, it appears to be adding the entire document as one article, not separate articles. How do I tell it to make some articles flow vertically, and others as new sections/articles horizontally?
    I'm a bit of a newbie, so appreciate any help here. I hope I don't have to split the document up in order to add them to the folio separately!
    Thanks!

    With InDesign CS5 and CS5.5, you have to split up the documents. To avoid frustration, you're going to want to watch a few videos or get a little training before diving in. See this getting started topic:
    http://help.adobe.com/en_US/digitalpubsuite/using/WS67cb9e293e2f1f60174dc2eb12f2ca67c28-80 00.html

  • IOS4 upgrade created multiple calendars out of one

    I use MobileMe to keep a "Master" calendar sync'd across all my devices - iPhone, iPad, laptop, etc. It has been working fine. After upgrading my 3G to iOS4, iCal on all my devices now shows multiple master calendars, with my "master" events spread out among them. It appears as if there is now a separate "Master" calendar for each of my devices - taken all together, they provide all the correct events as before. However, I also publish my Master calendar so my wife can see it in her iCal. She now sees only those events from one of the masters. Is there a way to merge all these calendars back into one? Thanks!

    I am having the same problem. I have now put on a new iphone and ipad. I now have over 30 home calendars.

  • How to create multiple spry menu in one site?

    Hello,
    I know it's been answered before but I couldn't get a step by step answer. I have a template already live.  It has a menu with 5 items. I need to add another menu with 7 items in one of the pages in the same site. How could I do this?
    Zandy Leonard
    [Personal contact info removed by moderator]

    Wouldn't it be simpler to add seven items to the menu you have now?
    If that can't fly, please read about Optional Regions.
    http://help.adobe.com/en_US/dreamweaver/cs/using/WScbb6b82af5544594822510a94ae8d65-7acca.h tml#WScbb6b82af5544594822510a94ae8d65-7acaa
    Nancy O.

  • How to get multiple records using fn-bea:execute-sql()

    Hi,
    I created Proxy service(ALSB3.0) to get records from DB table. I have used Xquery function(fn-bea:execute-sql()). Using simple SQL query I got single record, but my table having multiple records. Please suggest how to get multiple records using fn-bea:execute-sql() and how to assign them in ALSB variable.
    Regards,
    Nagaraju
    Edited by: user10373980 on Sep 29, 2008 6:11 AM

    Hi,
    Am facing the same issue stated above that I couldnt get all the records in the table that am querying in the Proxyservice.
    For example:
    fn-bea:execute-sql('EsbDataSource', 'student', 'select Name from StudentList' ) is the query that am using to fetch the records from the table called StudentList which contains more than one records like
    Id Name
    01 XXX
    02 YYY
    03 ZZZ
    I tried to assign the result of the above query in a variable and while trying to log the variable, I can see the below
    <student>
    <Name>XXX</Name>
    </student>
    I want to have all the records from my table in xml format but it's not coming up. I get the value only from the first row of my table.
    Please suggest.
    regards,
    Venkat

  • How to create multiple instance on same database

    Hi ,
    I would like to know how to create multiple instance on same database . I know that some people use database configuration assistant to do this but i could not figure out how they did it.
    Any how if some one can help me with this and can give me links of this it would be great help for me.
    Thank you for reading my problem and helping me !
    Amil
    please if possible mail me on [email protected]

    How to create multiple instance?????Do you mean multiple instances on the same database, or multiple databases on the same machine ?
    I m new to this field....
    Willin to learn a lot about oracle....Then it wouldn't be bad reading a bit of Database Concepts

  • How to select multiple records from a TREE in the table

    HI,
    I have a tree structure which is in the table.When I open the node of the tree,all the subnodes are coming as one-one records in the table.I want to slect multiple record from this table.I applied onLeadSelect for this table,I can select only 1 record from the table.
    Can any one plz suggest me how to select multiple records from the table so that I can get all the data of those selected record.
    Regards
    -Sandip

    Rashmi/Kukku,
    First of all, Thanks for your help!
    Is there any other way in which we can access tables other than using BAPIs or RFCs?
    In my case, there is a table structure which has to be updated with values after validating a key. i don't think there is any RFC available now. do i need to create bapi/rfc for that?
    Krishna Murthy

  • How to create multiple Tree Type Region In Tabular Form ?

    Dear Friends,
    i have to design tabular form to Distribute User Rioght to emp to access application
    eg if i have Three module in application
    1.Administration
    2.Attendance
    3.Accounts
    Module
    1 Administration have 5 Pages A,B,C,D,E.
    Module
    2 Attendance HAVE 4 Pages F,G,H,I
    Module
    3 Accounts HAVE 7 Pages J,K,L,M,N,O,P
    I need these three module divided into three section in tabular form as a tree Type like
    Module 1 Tree Open in Tabular Form like
    - (Tree Mark Open )
    =======================================================
    PAGE_ID-------------SUBPAGE_ID-------VIEW-------------------MODIFY-------------------CREATE----------------------------TABLE COLUMN NAME
    ========================================================          
    Administration-----------A------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Administration-----------B------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Administration-----------C------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Administration-----------D------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Administration-----------E------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    - (Tree Mark Open )
    Module 2 Tree Open in Tabular Form like
    Attendance-----------F------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Attendance-----------G------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Attendance-----------H------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Attendance-----------I------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    - (Tree Mark Open )
    Module 3 Tree Open in Tabular Form like
    Accounts-------------J------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Accounts-------------K------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Accounts-------------L------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Accounts-------------M------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Accounts-------------N------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Accounts-------------O------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Accounts-------------P------------------CHECK bOX------------CHECK BOX-------------CHECK BOXi need divided these three Module in Tabular form in three region as tree.
    Table APPLICATION_PAGE_DETAILS
    ID                   NUMBER
    PAGE_ID             NUMBER
    SUB_PAGE_ID          NUMBER
    ========================
    TABLE USER_RIGHT
    ======================
    ID                  NUMBER
    EMP_ID            NUMBER
    PAGE_ID            NUMBER
    SUB_PAGE_ID        NUMBER
    VIEW                    VARCHAR2(1)
    MODIFY                VARCHAR2(1)
    CREATE                VARCHAR2(1)How to create multiple Tree Type Region In Tabular Form ?
    How can i do this ?
    Thanks
    Edited by: Vedant on Oct 4, 2011 3:21 AM
    Edited by: Vedant on Oct 4, 2011 9:09 PM
    Edited by: Vedant on Oct 13, 2011 8:57 PM

    Well think of it I believe the scenario is too bird viewed hence the solution can't be exact.
    But thinking of a possible solution every time a child operation fails have a catch block where you you go back to system if the parent needs to be deleted if yes, call Delete Method on the parent.
    Note: Make sure that the decision on whether or not the parent record needs to be deleted will depends on the question "Does Parent Record already has several other children associated to it or not"
    Hope this clarifies.
    Regards,
    Messer

  • How to create multiple pages in the output file?

    hi, we have an application (C++) that generates PDF output. I've been asked to figure out how to create multiple copies of each page (uncollated). i.e. the output would be 4 copies of p 1 followed by 4 copies of p 2, etc. I'd like to do this without actually replicating each page if possible ... any ideas?

    Why not just put four copies of the same CosObj reference into the Pages array/tree?

Maybe you are looking for

  • Confirmation of service

    Hi everyone, When I am doing a goods issue for non stock materials (item category : TAX) it gives me a "confirmation of service". I understand there are no stock movements for non stock materials. But where exactly is this setting maintained that doe

  • Events in iCal are duplicated on my iPhone

    Changes made to iCal on my phone (moved or added events) are not getting synced to my iCal on my desktop though I have "sync Calendars" checked in iTunes.  Meanwhile on my 3S phone, I am getting events showing up in duplicate or triplicate even.  Exa

  • Error When Trying To Publish In Visual Studio 2013 C# Project

    I have a C# Winforms app in Visual Studio that has a problem. when I click on Project->Properties->Publish and click on the Options button, I get a prompt saying "An error occurred trying to load the page. An item with the same key has already been a

  • Project folder location

    When using Flex 2, I had my project folder in a separate location from the local "publish" folder (in Inetpub) - i.e. the mxml files etc were in my usual SVN repository, and the swf's got published to Inetpub. In Flex 3, it seems I can't do that when

  • Change color scheme of Terminal in XFCE4 ? *SOLVED*

    The default install of XFCE4 has a terminal with black text on white background. I find it a bit too bright, and its not as easy on the eyes as white text on black bg. When I used to use KDE, the terminal came with 'themes', one of them being 'linux