Insert multiple rows into a same table from a single record

Hi All,
I need to insert multiple rows into a same table from a single record. Here is what I am trying to do and I need your expertise. I am using Oracle 11g
DataFile
1,"1001,2001,3001,4001"
2,"1002,2002,3002,4002"
The data needs to be loaded as
Field1      Field2
1               1001
1               2001
1               3001
1               4001
2               1002
2               2002
2               3002
2               4002
Thanks

You could use SQL*Loader to load the data into a staging table with a varray column, then use a SQL insert statement to distribute it to the destination table, as demonstrated below.
SCOTT@orcl> host type test.dat
1,"1001,2001,3001,4001"
2,"1002,2002,3002,4002"
SCOTT@orcl> host type test.ctl
load data
infile test.dat
into table staging
fields terminated by ','
( field1
, numbers varray enclosed by '"' and '"' (x))
SCOTT@orcl> create table staging
  2    (field1  number,
  3     numbers sys.odcinumberlist)
  4  /
Table created.
SCOTT@orcl> host sqlldr scott/tiger control=test.ctl log=test.log
SQL*Loader: Release 11.2.0.1.0 - Production on Wed Dec 18 21:48:09 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
Commit point reached - logical record count 2
SCOTT@orcl> column numbers format a60
SCOTT@orcl> select * from staging
  2  /
    FIELD1 NUMBERS
         1 ODCINUMBERLIST(1001, 2001, 3001, 4001)
         2 ODCINUMBERLIST(1002, 2002, 3002, 4002)
2 rows selected.
SCOTT@orcl> create table destination
  2    (field1  number,
  3     field2  number)
  4  /
Table created.
SCOTT@orcl> insert into destination
  2  select s.field1, t.column_value
  3  from   staging s, table (s.numbers) t
  4  /
8 rows created.
SCOTT@orcl> select * from destination
  2  /
    FIELD1     FIELD2
         1       1001
         1       2001
         1       3001
         1       4001
         2       1002
         2       2002
         2       3002
         2       4002
8 rows selected.

Similar Messages

  • Merging of multiple rows in an internal table as a single record

    Hi All,
    I have an internal table which has the following columns:
    text, date, time, user.
    it stores notes in the internal table.
    The problem is...when I save a note with multiple lines and spaces it saves each line of the note as a row in the internal table.
    Thus i get more no. of rows in the internal table compare to the no. of rows!
    I need to store each notes as single row in the internal table.
    Please advise how to approach this?
    Helpful answers will be rewarded.
    Thanks & Regards,
    Anshumita.

    You can create a deep internal table. You can declare one Column as an internal table and store the NOTES in that Internal table for each row.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb366d358411d1829f0000e829fbfe/content.htm
    you can check the example in the link
    regards,
    abhishek

  • Inserting Multiple Rows into Database Table using JDBC Adapter - Efficiency

    I need to insert multiple rows into a database table using the JDBC adapter (receiver).
    I understand the traditional way of repeating the statement multiple times, each having its <access> element. However, I am just wondering whether this might be performance-inefficient, as it might insert records one by one.
    Is there a way to ensure that the records are inserted into the table as a block, rather than record-by-record?

    Hi Bhavesh/Kanwaljit,
    If we have multiple ACCESS tags then what happens is that the connection to the database is made only once. But the data is inserted row by row.
    Why i am saying this?
    If we add the following in JDBC Adapter..logSQLStatement = true. Then incase of multiple inserts we can see that there are multiple
    <i>Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','1000')
    Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','2000')</i>
    Doesnt this mean that rows are inserted one by one?
    Correct me if i am wrong.
    This does not mean that the transaction is not guaranted. Either all the rows will be inserted or rolled back.
    Regards,
    Sumit

  • Inserting multiple rows into a table (using sequences)

    Hi!
    I want to insert multiple rows into a db table, but I don't know how.
    I know how to insert 1 row using a sequence:
    I put all the fields in the jsp form's page and in the submit page I put something like this:
    <jbo:Row id="myRow" datasource="ds" action="Update" rowkeyparam="MyRowKey" >
    <jbo:SetAttribute dataitem="*" />
    </jbo:Row>
    But how can I insert multiple rows like this:
    Id          Name
    1          ana
    2          monteiro
    3          maria
    Thanks!

    Hi Chris,
    I think this should give you what you need: Working with a Multiple Select List Item
    --Jennifer                                                                                                                                                                                                                                                                                                                                                                                                   

  • Inserting multiples rows into a table using function or procedure..

    How do i insert multiples rows into a table using function or procedure?
    Please provide me query..

    Use FORALL bulk insert statement...
    eg:
    procedure generate_test_data as
    type cl_itab is table of integer index by pls_integer;
    v_cl_itab cl_itab;
    type cl_vtab is table of varchar2(25) index by pls_integer;
    v_cl_vtab cl_vtab;
    type cl_dtab is table of date index by pls_integer;
    v_cl_dtab cl_dtab;
    begin
    for i in 1.. 100 loop
              v_cl_itab(i):= dbms_random.value(1,1000);
              v_cl_vtab (i):=dbms_random.string('a',20);
              v_cl_dtab (i):=to_date(trunc(dbms_random.value(2453737, 2454101)),'j');          
         end loop;
         forall i in v_cl_itab.first .. v_cl_itab.last
              execute immediate 'insert into test_order values( :n, :str , :dt ) ' using v_cl_itab(i), v_cl_vtab (i), v_cl_dtab (i);          
         commit;
    end;

  • To insert multiple rows by getting the values from the user

    Hi
    I want to insert multiple rows into a table using user given values dynamically.
    I am a beginner to PL/SQL. Below code is part of my big code. A_row_insert is 2 and A_count is 1 (initially). While i execute , it asks for input only once and insert the same data 2 times. I want to enter two different rows. Please guide/advise me on this.
    while (A_count<=A_row_insert) loop
    dbms_output.put_line('Enter the value  for the row#'||A_count||' of the table '||v_req_tab_name||':');
    begin
    INSERT INTO customers (
    customer# ,
    lastname ,
    firstname ,
    address ,
    city ,
    state ,
    referred ,
    region
    +)+
    VALUES
    +(+
    +&customer,+
    +'&lastname' ,+
    +'&firstname' ,+
    +'&address' ,+
    +'&city' ,+
    +'&state' ,+
    +&referred ,+
    +'&region'+
    +);+
    end;
    A_count := A_count 1;+
    end loop;
    regards
    Sakthivel

    hi,
    You need to write a procedure and call it from front end for n number of time..... check the parameters you need to pass to execute the procedure.... try given sample....
    CREATE OR REPLACE PROCEDURE InsertData(i_code IN VARCHAR2,i_code_desc IN VARCHAR2,i_code_type IN VARCHAR2)
    AS
    BEGIN
         INSERT INTO CODE_MASTER (code,code_desc,code_type)
    VALUES(i_code,i_code_desc,i_code_type);
    EXCEPTION WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE ( 'Error during Insert code - '||i_code );
    END;
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    exec InsertData('code1','desc1','type1');
    Thnx MB

  • Insert Multiple rows into the table from that table data

    Hi All,
    I have a requirement like to insert mulitple rows into the table from that table data only(I need to replicate the data).
    In this table primary key is composite primary key with all foreign keys.primary key also including the Date foreign key.I need to change that date at the of insertion.
    INSERT
    INTO myschema.Fact_page_performance
    time_sk ,
    batch_id ,
    delta_msec ,
    delta_user_msec,
    error_code_sk ,
    content_errs ,
    element_count ,
    page_bytes ,
    Available ,
    date_sk
    VALUES
    (SELECT time_sk ,
    batch_id ,
    delta_msec ,
    delta_user_msec,
    error_code_sk ,
    content_errs ,
    element_count ,
    page_bytes ,
    Available
    FROM myschema.FACT_PAGE_PERFORMANCE_BACKUP
    WHERE date_sk=20090509,20090510
    But it is giving the error like missing Expression.
    Could anyone please help to me.
    Thanks and Regards
    Swetha.

    You can have either VALUES or SELECT not both
    INSERT
    INTO myschema.Fact_page_performance
    time_sk ,
    batch_id ,
    delta_msec ,
    delta_user_msec,
    error_code_sk ,
    content_errs ,
    element_count ,
    page_bytes ,
    Available ,
    date_sk
    SELECT time_sk ,
    batch_id ,
    delta_msec ,
    delta_user_msec,
    error_code_sk ,
    content_errs ,
    element_count ,
    page_bytes ,
    Available
    FROM myschema.FACT_PAGE_PERFORMANCE_BACKUP
    WHERE date_sk=20090509,20090510;

  • Insert multiple rows into table

    Hi,
    I want to insert into multiple rows into a table,say 1m rows.
    Can somebody help me out...
    Thanks

    rp0428 wrote:
    >
    ALTER TABLE t1 NOLOGGING;
    insert /*+ append */ into t1 select col1, col2, col3 from source_table;
    alter table test_table logging;
    >
    It's usually standard practice that if you set a table (e.g. 't1' in your example) to NOLOGGING then you should set the same table back to LOGGING after the insert. Setting table 'test_table' to LOGGING isn't really what you intended is it? ;)Ohh yes, It was a Typo. I am so accustomed to Test_table on OTN that I forgot, I had actually used the table T1 in demonstration.
    I meant as below
    ALTER TABLE t1 NOLOGGING;
    insert /*+ append */ into t1 select col1, col2, col3 from source_table;
    alter table t1 logging;Thanks for correcting me :)

  • Inserting Multiple Rows into a Table

    I am having problems insert multiple rows. I am using Table1.Row1.instanceManger.addInstance(1).
    I try adding another line using
    Table1.Row2.Cell2.value.#text= "TEST"
    and I get an error acessor is unknown. I assume this is an index issue. Can someone tell me if I am doing this wrong and discuss table indexes?

    The first thing I notice is that your variable, "num," isn't initialized in the FOR loop like I'm used to seeing.. The next thing I would try would be declaring my variables outside of the loop. Something like this maybe.
    String query = null;
    Statement stmt = null;
    int rowsUpdated = 0;
    for (int num = 0; num < 10; num++);     {
         query = "INSERT into apartment (apartmentID,blockID) VALUES ('"+num+"','"+aid+"')";
         stmt = con.createStatement();
         rowsUpdated += stmt.executeUpdate(query);
    }Let me know how it goes.
    -Aaron
    http://www.WeKnowErrors.com/ A free Wiki for error codes and computer problems.

  • Inserting multiple rows into a table using a multiple-select list

    I'm trying to figure out how to take the output of a multiple-select list (":" separated list of values) and use that to update a table by inserting multiple rows based on the values. Is there a straight-forward way to do that in APEX?
    Thanks.
    Chris

    Hi Chris,
    I think this should give you what you need: Working with a Multiple Select List Item
    --Jennifer                                                                                                                                                                                                                                                                                                                                                                                                   

  • Multiple row update of a table from another one

    Im trying to make a multiple row update with date from a different table, but it's giving me an error.
    update inv.mtl_system_items_b
    set attribute1 = t2.description,
        last_update_date = SYSDATE,
        last_updated_by = 3606
    from inv.mtl_system_items_b t2
         inner join TMP.TMP_INACTIVAR_PRODUCTOS t1
         on t2.segment2 = t1.inventory_item_id;Edited by: user8986013 on 21-may-2010 14:15

    Hi,
    Whenever you have a question involving an error message, post the complete error message, including line number. Don't you think that might help people solve your problem?
    Whneve you have any question, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data. (In the case of a DM<L statement, like UPDATE, the INSERT statements show the tables before the change, and the results are the contents of the changed table after it.)
    Review the syntax of the UPDATE statement in the SQL Language manual:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10008.htm#sthref9598
    MERGE may be more efficient and easier to use than UPDATE.

  • Inserting multiple rows into DB via SQL insert or stored procedure?

    I have successfully created an application where I select a row in an output table view from a Microsoft Access DB SQL data source, and get an Oracle stored procedure to save the row in a new table in our Oracle DB.
    This works like a charm when selecting one single row in the table view. What I really need though is for the procedure to save multiple rows at once.
    My table is configured with selection mode = 'multiple', and the data mapping line between the table and my procedure has mapping scope = 'selected data rows'.
    So, I am able to select multiple rows but still my procedure only stores one of the values sent. Does anyone know if this is related to my procedure not handling multiple parameter entries or if it's related to how VC outputs data to a procedure?
    Here is output from runtime flex log where you see the three values: 3, 11 and 9 that is sent to the procedure's IN parameter 'P_ID'.
    <Row OWNAPPS_TESTSQL_HYTTER_P_ID="3"/><Row OWNAPPS_TESTSQL_HYTTER_P_ID="11"/><Row OWNAPPS_TESTSQL_HYTTER_P_ID="9"/>
    Please help
    Henning Strand
    I am still very, very interested in hearing if anyone has been successful at passing multiple rows to a stored procedure in one submit action.
    Edited by: Henning Strand on Apr 11, 2008 1:58 PM

    Update for all you happy people using Oracle stored procedures with Visual Composer:
    When trying to run a simple procedure that accepts arrays as input parameters, the JDBC connector returns an error message saying: 'PLS-00306: wrong number or types of arguments in call ...'
    I registered this as a customer message with sap support and got an answer back saying:
    Unfotunately our JDBC connector is still not able to work with SP that contain arrays, this is the reason for the behaviour that you're seeing.
    This are the bad news, the good news is that with WebServices we don't have this limitation, so you can achieve the same results by using a WS instead of the Store Procedure.
    I have asked if and when using stored procedures with arrays will be supported - waiting for answer.
    Henning Strand

  • How to create multiple rows in a child table from the multi select Lov

    Hi
    We have Departments and EmployDept and Persons tables and each employee can associate multiple departments and vice versa.While creating a Department page there should be a Multi Select LOV(values from Persons table) with search option for the Persons.From the search panel we can select multiple persons for that department.Suppose we have selected 5 persons and click on submit, then it should create 5 rows in the EmployDept table for 5 persons with that department id.
    Any inputs on how to implement this scenario please..

    Maybe you can get some ideas from here -
    http://adfdeveloper.blogspot.com/2011/07/simple-implementation-of-af.html

  • How to insert multiple rows in the database table with the high performance

    Hello everybody,
    I am using the struts,jsp and spring framework. In my application there are 100s of rows i have to insert into the database 1 by 1. I am using usertransaction all other things are working right but i am not getting the real time performance.
    Can anyone tell me the proper method to insert multiple records and also with fast speed

    I don't know much about Spring etc, but if the jdbc Statemenet.addBatch(), Statement.executeBatch() statements let you bundle a whole lot of sql commands into one lump to execute.
    Might help a bit...

  • Insert Multiple Rows into a Database

    Hi,
    I've been working on a project that takes an xml document from JMS queue and inserts the data into db. But the problem here is that there can be any number of data sets. I've been using OEPE for my task, but no matter what I do, the data simply isn't inserted. Could any body please help me? Here is a sample message that I'm trying to insert, as well as the XSDs for the JCA and the input documents.
    XSD for JMS Message:
    <?xml version="1.0" encoding="windows-1252" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.example.org"
    targetNamespace="http://www.example.org"
    elementFormDefault="qualified">
    <xsd:element name="cannonical">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="orders">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="data" maxOccurs="unbounded">
         <xsd:complexType>
              <xsd:sequence>
                   <xsd:element name="rowCode" type="xsd:string"/>
                   <xsd:element name="productNumber" type="xsd:string"/>
                   <xsd:element name="attributeType" type="xsd:string"/>
                   <xsd:element name="attributeCode" type="xsd:string"/>
                   <xsd:element name="transactionType" type="xsd:string"/>
                   <xsd:element name="timestamp" type="xsd:dateTime"/>
              </xsd:sequence>
         </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    JCA XSD:
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <xs:schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/top/InsertData" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/top/InsertData" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="OrderDataCollection" type="OrderDataCollection"/>
    <xs:complexType name="OrderDataCollection">
    <xs:sequence>
    <xs:element name="OrderData" type="OrderData" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="OrderData">
    <xs:sequence>
    <xs:element name="prodnum" type="xs:decimal"/>
    <xs:element name="attrtype" minOccurs="0" nillable="true">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="20"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="attrcode" minOccurs="0" nillable="true">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="10"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="transtype" minOccurs="0" nillable="true">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="1"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="ordertime" type="xs:dateTime" minOccurs="0" nillable="true"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    Sample Input:
    <?xml version="1.0" encoding="windows-1252"?>
    <ProductData>
    <header>
    <rowCode>H</rowCode>
    <interfaceCode>H6D9J7</interfaceCode>
    <createdOn>
    <date>
    <year>2011</year>
    <month>05</month>
    <day>23</day>
    </date>
    <time>
    <hour>02</hour>
    <minute>05</minute>
    <seconds>11</seconds>
    </time>
    </createdOn>
    <description>Front Shop Item Attributes from FMS to JDA PMM</description>
    </header>
    <body>
    <data>
    <rowCode>D</rowCode>
    <productNumber>0004567</productNumber>
         <attributeType>TTTTTT</attributeType>
    <attributeCode>CCCCCCCjjj</attributeCode>
         <transactionType>A</transactionType>
    <timestamp>
    <date>
              <year>2011</year>
    <month>02</month>
              <day>19</day>
         </date>
         <time>
         <hour>02</hour>
    <minute>05</minute>
    <seconds>11</seconds>
    </time>
    </timestamp>
    </data>
         <data>
    <rowCode>D</rowCode>
    <productNumber>0004567</productNumber>
    <attributeType>TTTTTT2</attributeType>
    <attributeCode>CCCCCCjjj2</attributeCode>
    <transactionType>A</transactionType>
    <timestamp>
    <date>
              <year>2011</year>
    <month>02</month>
              <day>19</day>
         </date>
         <time>
         <hour>02</hour>
    <minute>05</minute>
    <seconds>11</seconds>
    </time>
    </timestamp>
    </data>
    </body>
    <footer>
    <rowCode>Z</rowCode>
    <interfaceCode>H6D9J7</interfaceCode>
    <numberOfRows>000000000002</numberOfRows>
    </footer>
    </ProductData>
    I'll be really grateful if anybody can help me out. Thank you.

    Check below link it may help you out
    how to Insert multiple records using single DB Adapter
    Thanks
    AJ

Maybe you are looking for

  • How do  I display more than one region as a modal popup?

    Hello all! I have a popup that displays a report region. I now want it to display more than one region, say a report region and another report region underneath it. Here's the code that I currently have (and this one can popup one region): $.fx.speed

  • BO 4.1 SP3 "Database Middleware Selection" - drivers missing

    Hello guys, I've looked up my problem and I saw 2-3 similar scenarios, but couldn't get any good answer from previous discussions, so I'm asking again. I have a BI Platform, 4.1 SP3. BO Server is installed on WIN 2008 R2. Client Tools machine is on W

  • Convert sap script to pdf and send mail before close_form

    hi experts, I am converting a sap script to PDF and then sending that pdf to vendor mail ids. I am getting the Data for the conversion of pdf From close_form.But it contains the data for all the vendors . But i have to Send the mail to the specific v

  • WD Java iView not opening in Safari

    Hi All, System: EP6.0 I have a WD Java iView in portal that opens fine with IE and Mozilla but shows a blank view on Safari. The same application when viewed directly via link http://<HOST>:<PORT>/webdynpro/dispatcher is also displayed properly on Sa

  • How to loop my own beats

    Hi - For the life of me I cannot figure out how to take a beat I have created and then loop it.  There is no "create loop" option as there was in previous versions.  Help please. Thanks