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

Similar Messages

  • 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                                                                                                                                                                                                                                                                                                                                                                                                   

  • 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.

  • 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;

  • Is this the fastest way to insert 100k rows into a database?

    I'm looking to insert ~100k rows into a database as fast as possible. I'm connected to the database through a small LAN with static IP adresses. The target database is running my SQL. Here's the fastest I've gotten the code so far. Task manager shows that it's only sending like 2.5mbps. If I take the size of the 2D array (64MB) and divide by the time it takes to transfer it currently, I calculate ~160kbps. Is that the best I can hope for with the NI DB Toolkit?
    CLD (2014)

    Hi,
    Use DB Tool Insert Data VI to insert the data in the database.
    You can insert complete row data at a time. No need to insert single-single element in database this will reduce your code performance.
    Thanks and Regards
    Himanshu Goyal | LabVIEW Engineer- Power System Automation
    Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
    It Only gets BETTER!!!

  • Inserting multiple rows into database using c#

    Hi,
    I have a web form with a customer id and a few checkboxes with different products (productid) and when a user checks the checkbox he must also enter a date for that product. 
    I need to basically do the following insert into Customer  (customerid,productid, purchasedate) values (1,890,18/12/2003)
    insert into Customer  (customerid,productid, purchasedate) values (1,56,12/12/2004)
    For each product checked I need to insert the details into the database with the same customerid.
    The database table looks like this:
    Customer Table
    CustomerId int
    ProductId int
    PurchaseDate datetime
    What is the correct way to do that? Should I change the database table?
    Thanks

    This has nothing to do with C#. Ask in the SQL forum for your database product for bulk insertion options.
    Visual C++ MVP

  • Inserting multiple records into a database from a table

    I have a dynamic table with rows upto 10. i am trying to insert all the records in these rows into a database ( msaccess)
    table name: Table1 ( in my form )
    Database table : movies_comments ( as posted in stefan's forums ).
    table columns: username, movieid, comments
    i am using the following code.
    Database.ExecSQL() function is as posted in stefcamerons forums.
    var tlength = xfa.resolveNode("form1.#subform[0].Table1.Row1[*]").length;
    xfa.host.messageBox("tlength is :" +tlength);
    for ( var i = 1; i <= tlength; i++)
    var username = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].user_name").rawValue;
    var movieID = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].movie_id").rawValue;
    var commentS = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].comment_").rawValue;
    Database.ExecSQL("INSERT INTO movie_comments (username, movieId, comment) VALUES ('username','movieID', 'commentS');");
    i am trying to insert multiple records using the code above. But i am getting error
    GeneralError: Operation failed.
    XFAObject.resolveNode:1:XFA:form1[0]:#subform[0]:Button1[0]:click
    SOM expression returned list when single result was expected
    suggest me an alternate way to insert multiple records from a table into a database.
    thank Q

    figured it out. I changed the ...OR (alternative names = colname) in the recordset to ...OR (alternative names LIKE %colname%). Works like a charm now- the result of a good night's sleep.

  • Can you use ESB to insert multiple records into a Database

    We have an XML file that has a Parent/Child relationship.
    In situation 1 we have a single parent record in the xml file. We can insert the record into the database successfully.
    In situation 2 we have a parent and a an associated child record. By using a filter expression to identify the existence of the child record we can route to the first DB Adapter to insert the parent then to the second DB Adapter to insert the child.
    Is this final scenario logical and also possible.
    Situation 3 we have multiple child records associated to a single parent. So we would first insert the parent record then insert all the child records.
    Thanks

    I use PL/SQL for this if you are using Oracle.
    Have a look at this post, it is for AQ but the concept can be used for PL/SQL
    Re: Can I pass a pl/sql table as a parameter from a database adaptor
    I will send you an example
    cheers
    James

  • 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 Images into oracle database using JDBC

    I wanted to insert multiple images into database using JDBC by reading it from the file... and i am passing photos.txt(my text file) as an input parameter... I have inserted all the values into the database except for the image part... this is my content of photos.txt file and i have copied all the images into the folder
    *" C:\\photos "*
    *1,in1.jpg,108,19,in-n-out*
    *2,in2.jpg,187,21,in-n-out*
    *3,in3.jpg,308,41,in-n-out*
    *4,in4.jpg,477,52,in-n-out*
    *5,in5.jpg,530,50,in-n-out*
    and i want to store in1.jpg,in2.jpg,in3.jpg,in4.jpg,in5.jpg into the oracle databse using JDBC.... i have tried a lot using BLOB column.... and i have created my table as
    CREATE TABLE PHOTO(
    ID NUMBER NOT NULL PRIMARY KEY ,
    Name BLOB,
    X DOUBLE PRECISION,
    Y DOUBLE PRECISION,
    Tags VARCHAR2(40)
      try {                 // for restaurant System.out.println();System.out.println();System.out.println(); System.out.print("  Creating Statement for Photo...\n");             stmt2 = con.createStatement ();                       stmt2.executeUpdate("delete from PHOTO"); stmt2.executeUpdate("commit"); PreparedStatement stmt3 = con.prepareStatement ("INSERT INTO PHOTO VALUES (?, ?, ?, ?, ?)");             System.out.print("  Create FileReader Object for file: " + inputFileName1 + "...\n");             FileReader inputFileReader2 = new FileReader(inputFileName1);             System.out.print("  Create BufferedReader Object for FileReader Object...\n");             BufferedReader inputStream2  = new BufferedReader(inputFileReader2);             String inLine2 = null;                         String[] tokens; //            String[] imageFilenames = {"c:\\photos\\in1.jpg","c:\\photos\\in2.jpg","c:\\photos\\in3.jpg","c:\\photos\\in4.jpg","c:\\photos\\in5.jpg", //  "c:\\photos\\in6.jpg","c:\\photos\\in7.jpg","c:\\photos\\in8.jpg","c:\\photos\\in9.jpg","c:\\photos\\in10.jpg","c:\\photos\\arb1.jpg","c:\\photos\\arb2.jpg", //  "c:\\photos\\arb3.jpg","c:\\photos\\arb4.jpg","c:\\photos\\arb5.jpg","c:\\photos\\den1.jpg","c:\\photos\\den2.jpg","c:\\photos\\den3.jpg", //  "c:\\photos\\den4.jpg","c:\\photos\\den5.jpg","c:\\photos\\hop1.jpg","c:\\photos\\hop2.jpg","c:\\photos\\hop3.jpg","c:\\photos\\hop4.jpg","c:\\photos\\hop5.jpg"};               File file = new File("C:\\photos\\in1.jpg");            \\ ( Just for example  )           FileInputStream fs = new FileInputStream(file);                         while ((inLine2 = inputStream2.readLine()) != null) {               tokens= inLine2.split(",");             st2 = new StringTokenizer(inLine2, DELIM);                                                             stmt3.setString(1, tokens[0]);               stmt3.setBinaryStream(2, fs, (int)(file.length()));               stmt3.setString(3, tokens[2]);               stmt3.setString(4, tokens[3]);               stmt3.setString(5, tokens[4]);               stmt3.execute(); //execute the prepared statement               stmt3.clearParameters(); 
    As i am able to enter one image file by above code in1.jpg in to the oracle database.... but i am not able to insert all the image file in to the database.....do tell me what should i do.... and can you give me the example on the basis of the above code of mine...
    do reply as soon as possible..

    jwenting wrote:
    that depends. Putting the images in BLOBs prevents the file locations stored in the database from getting out of synch with the filesystem when sysadmins decide to reorganise directory structures or "archive" "old" files that noone uses anyway.True, but it really comes down to a business decision (cost-benefit analysis). If you have the bucks, the expertise, and the time, go with the Blobs, otherwise go with the flat files.

  • 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 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                                                                                                                                                                                                                                                                                                                                                                                                   

  • 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;

  • 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...

Maybe you are looking for