Multiple table insert xml to mssql

Hello experts,
I am trying to insert the data of an xml file into 3 target tables (mssql).
The dependencies are the following:
tables: --- timesheetcode -- assignment -- workhours
attribute: --- tsCodeId - - - - - - tsCodeId - - - - - - assignmentId
So there is a parent-child relationship between the tables. The tsCodeId and the AssignmentId are being created as an 16 byte uniqueIdentifier. So when creating multiple interface to do these inserts how do I get the generated Id's that I need for the childs? I found the following topic but it is oracle based and I don't think this fully solves my problem:
How to load multiple target tables simultaneously in single interface?
thanks a lot for your suggestions
Edited by: iadgroe on Apr 30, 2012 12:42 AM

If your XML file contains these relationships in form of nested tags, then you dont have to worry.
ODI reverse engineering will create an XML data model that will maintain the relationship of data with ODI generated surrogate keys.
Then you can load your data one by one in to timesheetcode, assignment and workhours using the corresponding interfaces from XML datastores.

Similar Messages

  • Xsql multiple table insert

    I'm having trouble getting my xml document inserted into multiple tables. My xml has a parent child relationship. The main node is the parent I'll call <CAKE> then later on in the xml doc it has a node called <INGREDIENTS> which is a repeating element (more than 1). I need to insert information from the root node, <CAKE> into 1 table and all the info from <INGREDIENTS> node into another table.
    I've tried to get Steve Muench's book a try (chapter 14) but when I try to run the examples from the book (XMLLoader) i get the following error.
    C:\jdev9i\jdk1.3\bin\javaw.exe -ojvm -classpath C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14\classes;C:\oracle\ora81\RDBMS\jlib\xsu12.jar;C:\jdev9i\lib\xmlparserv2.jar;C:\jdev9i\jdev\lib\jdev-rt.jar;C:\jdev9i\jdbc\lib\classes12.jar;C:\jdev9i\jdbc\lib\nls_charset12.jar;C:\jdev9i\jlib\jdev-cm.jar;C:\jdev9i\rdbms\jlib\xsu12.jar;C:\jdev9i\lib\xmlparserv2.jar;C:\jdev9i\lib\xmlcomp.jar;C:\jdev9i\lib\oraclexsql.jar;C:\jdev9i\rdbms\jlib\xsu12.jar;C:\jdev9i\lib\xsqlserializers.jar;C:\jdev9i\lib\xmlparserv2.jar;C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14\classes;C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14\classes;C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14\classes -
    mx50m
    XMLLoader -file deptempdepend.xml -transform deptempdepend.xsl
    Processed 1 Documents
    Node doesn't belong to the current document.
    Error: java.lang.NullPointerException
    Process exited with exit code 0.

    I made the changes in the java files as per the previous
    reference, but I'm still getting an error. Seeing that I'm not
    much of a Java guy yet, I'm not sure where to debug the error.
    So here it is:
    XMLLoader -file deptempdepend.xml -transform deptempdepend.xsl
    Processed 1 Documents
    null
    Error: java.lang.NullPointerException
    Process exited with exit code 0.
    I tried to debug it and came to the conclusion that it is
    failing at line 22 of ConnectionFactory
    The value connNode is returend as null.
    I don't understand why:
    I ran testxpath.exe for the connections file.
    C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14>testxpath connections.xml
    Type an XPath expression to test and press [Enter]
    To quit, press [Enter] without entering a path.
    connections.xml> /connections/connection[@name='doug']
    <connection name="doug">
    <username>user</username>
    <password>password</password>
    <dburl>jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=
    (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))
    (CONNECT_DATA=(SERVICE_NAME=dtxml.hmms)))</dburl>
    <driver>oracle.jdbc.driver.OracleDriver</driver>
    </connection>
    connections.xml>
    and it returned what i thought would be the correct nodes.
    Any help would be appreciated
    Doug

  • Multiple-table inserts

    Hi,
    As part of a project I am working on I need to insert records into 3 tables and have to write a stored procedure for that. An e.g to that affect is as follows:
    Say I have 3 tables NAMES (lname,fname), ADDRESS(addr1,addr2), PHONE(hphone). How do I write a single stored proedure that takes five arguments (lname,fname,addr1,addr2,hphone) and insert these into each of the tables mentioned above. I want to do these in the context of one transaction. I.e. if in the worse case scenario I loose connection to the database after inserting into NAMES, ADDRESS tables, I should rollback the transaction because as the hphone has not been inserted into the PHONE table.
    I would greatly appreciate any input on this issue.
    Thanks.

    Just a quick example :
    SQL> insert into mytable1 select * from all_objects where rownum<=10;
    10 rows created.
    SQL> insert into mytable2 select * from all_objects where rownum<=10;
    10 rows created.
    SQL> <--------------- here, from an other session, I kill the current one
    SQL> select count(*) from mytable1 ;
    select count(*) from mytable1
    ERROR at line 1:
    ORA-00028: your session has been killed
    SQL> conn sysadm/****@mydb
    Connected.
    SQL> select count(*) from mytable1 ;
      COUNT(*)
             0
    SQL> select count(*) from mytable2;
      COUNT(*)
             0
    SQL> As expected, no rows in neither of the tables, insert statement haven't been committed.
    Of course, you shouldn't explicitly commit yourself between the insert statement to keep the data consistency. That's say, I wouldn't understand why search insert in one time into three tables with different structure.
    There is solution to insert into multitable in one time, but not to avoid what you think, see exemple here.
    Nicolas.

  • INSERT ALL - Multiple table insert issue

    There are three tables A, B, C. A has three rows. It has record of table B + 1 row. B has two rows, has record of table C + 1 row. C has one row.
    SQL> SELECT * FROM A;
            C1         C2                                                          
             1          1                                                          
             2          2                                                          
             3          3                                                          
    SQL> SELECT * FROM B;
            C1         C2                                                          
             1          1                                                          
             2          2                                                          
    SQL> SELECT * FROM C;
            C1         C2                                                          
             1          1                                                          
    I need to write a single query which make rows equal in all tables. I use INSERT ALL WHEN INTO method but get following errors:
    SQL> INSERT ALL
      2  WHEN A.c1 NOT IN ( SELECT c1 FROM B) THEN
      3  INTO B VALUES(A.c1, A.c2)
      4  WHEN A.c1 NOT IN (SELECT c1 FROM C)  THEN
      5  INTO C VALUES(A.c1, A.c2)
      6  SELECT c1, c2 FROM A;
    INTO C VALUES(A.c1, A.c2)
    ERROR at line 5:
    ORA-00904: "A"."C2": invalid identifier
    However when I change columns names of all table and change INSERT ALL clause. I was able to execute it:
    SQL> select * from a;
            A1         A2                                                          
             1          1                                                          
             2          2                                                          
             3          3                                                          
    SQL> select * from b;
            B1         B2                                                          
             1          1                                                          
             2          2                                                          
    SQL> select * from c;
            C1         C2                                                          
             1          1                                                          
    SQL> INSERT ALL
      2  WHEN A1 NOT IN ( SELECT B1 FROM B) THEN
      3  INTO B VALUES(A1, A2)
      4  WHEN A1 NOT IN (SELECT C1 FROM C)  THEN
      5  INTO C VALUES(A1, A2)
      6  SELECT A1, A2 FROM A;
    3 rows created.
    My question is: What is the error with previous syntax? Is there any limitation of INSERT ALL statement.

    Thanks guys  for prompt response.
    I remove tablename aliase and it worked.
    SQL>  INSERT ALL
      2    WHEN c1 NOT IN ( SELECT c1 FROM B) THEN
      3    INTO B VALUES(c1, c2)
      4    WHEN c1 NOT IN (SELECT c1 FROM C)  THEN
      5    INTO C VALUES(c1, c2)
      6    SELECT c1, c2 FROM A;
    3 rows created.
    SQL> select * from c;
            C1         C2
             1          1
             2          2
             3          3
    SQL> select * from b;
            C1         C2
             1          1
             2          2
             3          3
    SQL> select * from a;
            C1         C2
             1          1
             2          2
             3          3
    SQL>
    I really thought it will give me ambiguity error in insert, as column names are same in other table. Generally it gives.
    Nice to know this thing of Multiple Insert

  • Multiple table insert via dblink

    Hi,
    We have an oracle database which contains a number of tables.
    From these tables I need to be able to populate a number of holding tables in a MSSQL database via a nightly scheduled job.
    Therefore I will insert into these tables via a procedure from my oracle tables.
    I need to ensure that if any of the inserts fail for a particular record I am uploading out of the five insert statements then the whole process is rolled back.
    I therefore having something like the following
    FOR cursor1_rec IN cursor1_cur LOOP -- This gives me the records I need to insert into the holding table for
    BEGIN
    INSERT into ms_holding_table_1
    (field1, field2)
    select 1,2 from oracle_table_1
    where id = cursor1_rec.id;
    INSERT into ms_holding_table_2
    (field1, field2, field3, field4)
    select 1,2,3,4 from oracle_table_2
    where id = cursor1_rec.id;
    INSERT into ms_holding_table_3
    (field1)
    select 1 from oracle_table_3
    where id = cursor1_rec.id;
    INSERT into ms_holding_table_4
    (field1, field2)
    select 1,2 from oracle_table_4
    where id = cursor1_rec.id;
    END;
    END LOOP;
    I need to ensure that if the insert for that particular cursor record fails on the 2nd insert statement, the first insert also rollbacks. Likewise if it fails on the 4th insert, I need to ensure that all 4 inserts are rolled back.
    If you could provide me with any information as to how to achieve this.
    Would issuing a savepoint before the first insert statement and then in my exceptions rolling back to the savepoint before the end of the loop suffice?
    Thanks in advance,
    ca84

    This is anonymous block but you can extend it add more defensive mechanism and def you can make it small procedure or part of some package. Hope this helps
    DECLARE
    CURSOR cur
    IS
    SELECT statement
    FROM table_name;
    BEGIN
    INSERT INTO ms_holding_table_1
    field1, field2
    SELECT 1, 2
    FROM oracle_table_1
    WHERE id = cursor1_rec.id;
    INSERT INTO ms_holding_table_2
    field1, field2, field3, field4
    SELECT 1, 2, 3, 4
    FROM oracle_table_2
    WHERE id = cursor1_rec.id;
    INSERT INTO ms_holding_table_3 (field1)
    SELECT 1
    FROM oracle_table_3
    WHERE id = cursor1_rec.id;
    INSERT INTO ms_holding_table_4
    field1, field2
    SELECT 1, 2
    FROM oracle_table_4
    WHERE id = cursor1_rec.id;
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN
    ROLLBACK;
    DBMS_OUTPUT.put_line (SUBSTR (SQLERRM, 1, 200));
    RAISE;
    END;

  • Multiple table insert using receiver jdbc adapter

    Hi,
    I am trying to insert data in to two tables in a single structure using receiver jdbc adapter. I am not using any stored procedure to insert data instead directly inserting the data using PI. Please see the structure I am using.
    SOURCE side:
    DT_ABC_SENDER
    --IT_HEADER_TEXT
      -- EBELN
      -- LINENO
      --TDTEXT
    --IT_ITEM_TEXT
      -- EBELN
      -- LINENO
      --TDLINE
    TARGET side:
    DT_ABC_RECEIVER
    --InsertStatement
         --HEADER_TEXT
                -- action                         (insert)
                -- Table                          (Table 1)
                --access
                     -- IDS_ENQ_NO
                     -- IDS_DESC
                     -- IDS_TEXT
       --ITEM_TEXT
                -- action                         (insert)
                -- Table                          (Table 2)
                --access
                     -- IIS_ENQ_NO
                     -- IIS_DESC
                     -- IIS_TEXT
    Using the above structure I am able to successfully insert the data in Table 1 but data is not getting inserted in Table 2.
    In sxmb_moni it is saying message successfully delivered but I but there is data insertion took place in Table 2.
    Please help me urgently.
    Thanks in advance.
    Neeeraj

    Hi Neeraj,
    Add --InsertStatement statement for the second table structure in the same level of first InsertStatement.
    Target structure like this:
    DT_ABC_RECEIVER
    --InsertStatement
         --HEADER_TEXT
                -- action                         (insert)
                -- Table                          (Table 1)
                --access
                     -- IDS_ENQ_NO
                     -- IDS_DESC
                     -- IDS_TEXT
    --InsertStatement
       --ITEM_TEXT
                -- action                         (insert)
                -- Table                          (Table 2)
                --access
                     -- IIS_ENQ_NO
                     -- IIS_DESC
                     -- IIS_TEXT

  • Referencing Records Across Multiple Tables in XML

    Post Author: rltimms
    CA Forum: Formula
    Here is my problem.
    I need to create a report that references data from 3 tables.  These 3 tables are linked through the use of two other tables.  The main tables I need to reference are entitled Station, Task, and Resource.  The Station table is linked to Task through a TaskStationMapping Table.  The Resource table is linked to Task through a TaskResourceMapping table.
    Here is how I would like the output to look.
    Station ID: S1 (L)
    Processes
    Required Resources
    Operator
    ID
    Description
    Net Time
    Take Rate
    Weighted Time
    Work Zone
    Models
    ID
    Quantity
    1
    6R-0000000003
    Install the center support retaining ring onto compressor tool with the bevel facing up.
    10.0000
    0.3000
    3.0000
    E
    2
    Brush - 1" Paint Brush (for loctite)
    1
    1
    6R-0000000004
    Get gauge.
    10.0000
    0.3000
    3.0000
    E
    2
    1
    6R-0000000011
    For 2-W/D models, visually verify the output shaft bearings have been installed.
    10.0000
    1.0000
    10.0000
    E
    The problem comes when I try to include the resource fields in my report.  Aside from the 2 fields on the far right, everything else comes from the task table.  I get this to display correctly for each station by creating a group using the ID from the Station table.  I then use a group select formula that Checks the Station.ID against the StationID from the TaskStationMapping table.  In order to get the fields from the task table to appear correctly I also have to include a formula that relates the ID from the Task Table and the TaskID from the TaskStationMapping table.
    Without those selection formulas I end up with just a list of all tasks, even tasks which arent mapped to the station for which that particular group has been created.
    Since the resources are mapped to the task, and not to the station, any type of selection statement I use to select from the resource table will affect my selections from the task table.  For example, if I select more specifically for the resources, not all tasks are displayed, only those mapped to resources, so from the above example, only the first line of the report would be shown.  I am new to using Crystal Reports, and I have no idea how to solve this problem.  I dont know if I am missing something in the Grouping stage that would make it so I dont have to use the group and record select functions, or if there is some other way to solve this problem.  Any help would be appreciated.

    Hi
    I am assuming that this is an offline form.
    First populate internal tables depending on the data you need on each page. Sort the table according to the PERNR.
    You can read the internal tables using Javascript -
    var varname1 = xfa.resolveNodes("xfa.record.ITAB.DATA[*]");
    Add the fields as per the first name - Name, last name etc and populate these fields with the first record from the first internal table. Store the PERNR value in a separate variable (say pernr1).
    Now you can querry the second internal table with this pernr, pick up the corresponding record and fill in the 2nd set of fields.
    for( var i = 0; i < varname1.length ; i++)
        if ( varname1.item(i).PERNR.value == pernr1 )
    Hope this is a good starting point for you.
    Thks, Liz

  • Reports using multiple tables

    I am trying to create a report using portal that use links between multiple columns. The info I want is mainly in two tables. Some of the info in the table is numeric (Foreign Keys). I want to display them in readable format so set up joins to the respective parent tables. When I do this the result only produces 12 lines of output irrespective of the number of lines I set per page. When I show only the data from the main tables, without the joins to the other parent tables, i.e. the foreign keys as numbers I get all the rows. I have tried to create the report by using all three options given but get the same result.
    I am using 9iAS verison 1.0.2.0 and Portal version 3.0.7.
    Can someone please explain why this happens and how I can solve this problem urgently.

    Hi Ashok,
    Sorry for posting the solution with delay. Actually I ran into the similar situation and upon deep analysis, I could crack it., the very next day.
    This is how your write back template should be for updating on multiple tables
    <?xml version="1.0" encoding="utf-8" ?>
    <WebMessageTables xmlns:sawm="com.siebel.analytics.web/message/v1">
    <WebMessageTable lang="en-us" system="WriteBack" table="Messages">
    <WebMessage name="WRITE">
    <XML>
    <writeBack connectionPool="Oracle Data Warehouse Connection Pool">
    <insert> </insert>
    <update> UPDATE FACT SET COUNT = '@{c4}', W_UPDATE_DT = CURRENT_DATE
    WHERE EXISTS (SELECT ROW_WID FROM DIM WHERE DIM.ROW_WID = FACT.DIM_WID AND
    DIM.X = '@{c1}' AND DIM.Y= '@{c2}' AND DIM.Z = '@{c3}' ) AND EXISTS (SELECT ROW_WID FROM DT WHERE DT.ROW_WID = FACT.DT_WID AND DT.PER_NAME_YEAR = '@{c0}') </update>
    </writeBack>
    </XML>
    </WebMessage>
    </WebMessageTable>
    </WebMessageTables>
    =====
    Using exits, will improve the performance.
    Hope it helps. If yes, pls award points. Thanks
    Regards,
    Sarat Nallapati

  • Inserting data from xml to multiple tables

    I have a requirement that i have to validate the xml file against the dtd and then insert the xml file data into multiple tables.Can anyone help me out on that front. I am developing a java application. Can i pass the xml file through stored procedure.???
    Any links to code or document regarding the above stated req will be appriciated
    Thanks in advance..

    This forum is dedicated to XML Type and XML DB which are features of the 9i and 9iR2 database. Questions related to XDK technology and legacy version of the database should be posted in the XML forum...
    http://forums.oracle.com/forums/index.jsp?cat=51
    I suspect that XDK technology may be a better solution to your problem

  • Updating/Inserting multiple tables

    Hi,
    I've been trying to figure out how to update/insert multiple fields in 2 different tables with one RowSet. im new to java and have been using Creator for about 2 weeks
    basically there are 3 tables: one containing user info(USER), one containing department info (DEPT), and one table relating the two (USER_DEPT). my form lets uers update, among others, their NAME in table USER, and DEPT_NAME in table DEPT.
    These are all VARCHAR types.
    I used the Clips provided by Creator to initialize and do the updating. i am using updateRow() to do the updating. the fields are bound to specific database fields. the RowSet is updatable.
    in my app i chose some specific fields, but for the sake of avoiding pasting very long SQL queries lets just say i chose everything. some of the queries i tried:
    SELECT *
    FROM USER WHERE USER.USERNAME = ?This one works.
    SELECT *
    FROM USER, DEPT, USER_DEPT
    where USER.ID = USER_DEPT.USER_ID
    and DEPT.ID = USER_DEPT.DEPT_ID AND USER.USERNAME = ?this one gives me a Conversion Error message. i have no conversion going on whatsoever. i havent even learned how to use conversion yet.
    another query i tried:
    SELECT * FROM USER
    INNER JOIN USER_DEPT ON USER.ID = USER_DEPT.USER_ID
    INNER JOIN DEPT ON DEPT.ID = USER_DEPT.DEPT_ID
    WHERE USER.USERNAME=?this one gives me no error. the app works except the database doesnt get updated. i have determined that when using this query updateRow() is skipped. i dont know why. the app keeps running in that it goes to the next page as defined by the XML, but updateRow() is never called.
    so can anyone please tell me how to update/insert multiple fields in multiple tables using one RowSet PLEASE?
    THANKS!

    The only way this can be done with a single rowset is if you do your query against a view (instead of a join), and if your JDBC driver supports updates to multiple tables through a view. Otherwise, you're going to need to update the underlying tables individually.
    Craig

  • XML into multiple tables

    This is my first thread so I hope I have formatted my request appropriately...
    If I have a simple XML doc with several records (see below) what is the best / easiest way to insert the data into multiple tables (Oracle 10g Release 1)?
    For example 3 tables:
    PATIENT table (CLAIMID, FNAME, LNAME, HEALTHNUM)
    ADDRESS table (CLAIMID, STREET, CITY, PROVINCE)
    SERVICE table (CLAIMID, SERVICE, ADMITDATE, DEPARTDATE)
    <?xml version="1.0"?>
    <CLAIMS>
    <CLAIM>
    <CLAIMID>1</CLAIMID>
    <FNAME>Oscar</FNAME>
    <LNAME>Grouch</LNAME>
    <HEALTHNUM>1234657890</HEALTHNUM>
    <STREET>123 Sesame Street</STREET>
    <CITY>Sesameville</CITY>
    <PROVINCE>ON</PROVINCE>
    <SERVICE>Heart Surgery</SERVICE>
    <ADMITDATE>2007-06-05</ADMITDATE>
    <DEPARTDATE>2007-06-11</DEPARTDATE>
    </CLAIM>
    <CLAIM>
    <CLAIMID>2</CLAIMID>
    <FNAME>Poppa</FNAME>
    <LNAME>Smurf</LNAME>
    <HEALTHNUM>0987654321</HEALTHNUM>
    <STREET>44 Blue Street</STREET>
    <CITY>Smurfville</CITY>
    <PROVINCE>ON</PROVINCE>
    <SERVICE>Lung Transplant</SERVICE>
    <ADMITDATE>2007-05-28</ADMITDATE>
    <DEPARTDATE>2007-06-04</DEPARTDATE>
    </CLAIM>
    ...more <CLAIM> records
    </CLAIMS>
    I can import the XML document into an XMLType column but don't know where to go from there...
    The extractValue method seems to work only when there is a single claim record in the XML document but a typical document will contain several hundred claims.
    Thanks in advance,
    M Kent

    Use the Oracle Berkeley DB XML to store the XML document in a embedded xml database. To store in the Oracle 10g database use XSU. With XSU an XML document may also be stored in multiple tables.
    http://download-east.oracle.com/docs/cd/A97329_03/web.902/a88894/adx07xsu.htm#1016732

  • XML document into multiple tables

    How to insert a xml document into multiple tables. Eg. Purchase Order having multiple line items. I have to insert xml document into Parent as well as child with different sets of columns.

    I created the tables using the create_ch14_tables.sql. I call it using java -classpath .;C:\commerceone\xpc\lib\xmlparserv2.jar;C:\commerceone\xpc\lib\classes12.zip;C:\commerceone\xpc\lib\xsu12.jar XMLLoader -file deptempdepend.xml -connName default -transform deptempdepend.xsl. The code doesn't seem to like the "<xsl:for-each select="Department">" tags. If I remove them, the insDoc.getDocumentElement().getFirstChild() will find the element, but it still doesn't insert anything into the database.
    Thank You,
    Dave

  • Data from table in xml Format and Inserting it into  Table

    Hi All
    I have table where xml data is stored in long format with xml tag know i have read the entire xml xoulmn which is xml tag and insert it into diffrent table can any suggest me the code
    Thanks & Regards

    I believe you are on the wrong forum. You want the XML DB forum.
    See:
    XML DB

  • In ADF how can i insert data in multiple table if they have foreign key

    I have started working on ADF and can anybody inform me in ADF how can i insert data in multiple table if they have foreign key,please?
    Thnak you very much.

    Hello,
    Still no luck.I am surely doing silly mistakes.Anyway,Here are my workings-
    1> student_mst (id(pk),studentname) and student_guard_mst(id(fk),guardianname)
    2> created EO from both of the tables,made id in both EO as DBSequence and an association was also generated.
    3> i made that association composite by clicking the checkbox
    4> i created 2 VO from 2 EO.
    5> put those VO in Application Module.
    6> dragged and dropped 2 VO on my jspx page and dropped them as ADF Form.
    Now what to do please?

  • What's the best way to insert/update thousands records in multiple tables

    Can anyone give an example of how to insert/update thousands records in multiple tables on performance wise? or what should I do to improve the performance?
    Thanks
    jim

    You can see a set of sample applications in various scenarious available at
    http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/content.html

Maybe you are looking for