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

Similar Messages

  • 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

  • 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

  • XML into multiple rows

    I have an XML file to inset into multiple tables.
    My file is like
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <DCDS>
    <CDS>
         <COD></COD>
         <COD_INT></COD_INT>
         <ULTIMA_MODIFICA></ULTIMA_MODIFICA>
         <TIP></TIP>
         <DEN></DEN>
         <CLS>
              <ID></ID>
              <DEN></DEN>
         </CLS>
         <FAC></FAC>
         <OBT>
         <![CDATA[
         ]]>
         </OBT>
         <PRF>
         <![CDATA[
         ]]>
         </PRF>
         <OCC>
         <![CDATA[
         ]]>
         </OCC>
         <ACC>
         <![CDATA[
         ]]>
         </ACC>
         <CUR>
              <ID></ID>
              <DEN></DEN>
                   <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT>
                   </SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT>
                   </SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT></SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT></SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT>
                   </SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT>               </SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT>               </SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT>
                   </SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
              <DESCAMBITO></DESCAMBITO>
    <SETT></SETT>     <CF></CF>
              <CFMIN></CFMIN>
              <CFMAX></CFMAX>
              <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
         <DESCAMBITO></DESCAMBITO>
              <SETT> </SETT>
              <CF></CF>
              <CFMIN> </CFMIN>
              <CFMAX> </CFMAX>
              <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
              <DESCAMBITO></DESCAMBITO>
              <SETT> </SETT>
                   <CF></CF>
                   <CFMIN> </CFMIN>
                   <CFMAX> </CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
              <DESCAMBITO></DESCAMBITO>
              <SETT> </SETT>
                   <CF></CF>
                   <CFMIN> </CFMIN>
                   <CFMAX> </CFMAX>
                   <TP></TP>
              </GRP>
                   <GRP>
                   <ID></ID>
                        <DESCAMBITO></DESCAMBITO>
              <SETT> </SETT>
                   <CF></CF>
                   <CFMIN> </CFMIN>
                   <CFMAX> </CFMAX>
                   <TP></TP>
                   </GRP>
         </CUR>
    </CDS>
    </DCDS>
    In some cases, like <GRP> tag, I have to insert multiple rows in a table. I found the valueOf, but it extracts only the first value contained.
    payment.amount := xpath.valueOf(curNode,'.');
    Some tips?

    I have an XML file to inset into multiple tables.
    My file is like
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <DCDS>
    <CDS>
         <COD></COD>
         <COD_INT></COD_INT>
         <ULTIMA_MODIFICA></ULTIMA_MODIFICA>
         <TIP></TIP>
         <DEN></DEN>
         <CLS>
              <ID></ID>
              <DEN></DEN>
         </CLS>
         <FAC></FAC>
         <OBT>
         <![CDATA[
         ]]>
         </OBT>
         <PRF>
         <![CDATA[
         ]]>
         </PRF>
         <OCC>
         <![CDATA[
         ]]>
         </OCC>
         <ACC>
         <![CDATA[
         ]]>
         </ACC>
         <CUR>
              <ID></ID>
              <DEN></DEN>
                   <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT>
                   </SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT>
                   </SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT></SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT></SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT>
                   </SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT>               </SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT>               </SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
                   <DESCAMBITO></DESCAMBITO>
                   <SETT>
                   </SETT>
                   <CF></CF>
                   <CFMIN></CFMIN>
                   <CFMAX></CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
              <DESCAMBITO></DESCAMBITO>
    <SETT></SETT>     <CF></CF>
              <CFMIN></CFMIN>
              <CFMAX></CFMAX>
              <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
         <DESCAMBITO></DESCAMBITO>
              <SETT> </SETT>
              <CF></CF>
              <CFMIN> </CFMIN>
              <CFMAX> </CFMAX>
              <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
              <DESCAMBITO></DESCAMBITO>
              <SETT> </SETT>
                   <CF></CF>
                   <CFMIN> </CFMIN>
                   <CFMAX> </CFMAX>
                   <TP></TP>
              </GRP>
              <GRP>
                   <ID></ID>
              <DESCAMBITO></DESCAMBITO>
              <SETT> </SETT>
                   <CF></CF>
                   <CFMIN> </CFMIN>
                   <CFMAX> </CFMAX>
                   <TP></TP>
              </GRP>
                   <GRP>
                   <ID></ID>
                        <DESCAMBITO></DESCAMBITO>
              <SETT> </SETT>
                   <CF></CF>
                   <CFMIN> </CFMIN>
                   <CFMAX> </CFMAX>
                   <TP></TP>
                   </GRP>
         </CUR>
    </CDS>
    </DCDS>
    In some cases, like <GRP> tag, I have to insert multiple rows in a table. I found the valueOf, but it extracts only the first value contained.
    payment.amount := xpath.valueOf(curNode,'.');
    Some tips?

  • Efficient Way of Inserting records into multiple tables

    Hello everyone,
    Im creating an employee application using struts framework. One of the functions of the application is to create new employees. This will involve using one web form. Upon submitting this form, a record will be inserted into two separate tables. Im using a JavaBean (Not given here) between the JSP page and the Java file (Which is partly given below). Now this Java file does work (i.e. it does insert a record into two seperate tables).
    My question is, is there a more efficient way of doing the insert into multiple tables (in terms of performance) rather than the way I've done it as shown below? Please note, I am using database pooling and MySQL db. I thought about Batch processing but was having problems writing the code for it below.
    Any help would be appreciated.
    Assad
    package com.erp.ems.db;
    import com.erp.ems.entity.Employee;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Collection;
    import java.util.ArrayList;
    public class EmployeeDAO {
         private Connection con;
         public EmployeeDAO(Connection con) {
              this.con = con;
         // METHOD FOR CREATING (INSERTING) A NEW EMPLOYEE
         public void create(Employee employee) throws CreateException {
              PreparedStatement psemployee = null;
              PreparedStatement psscheduleresource = null;
              String sqlemployee = "INSERT INTO employee (FIRSTNAME,SURNAME,GENDER) VALUES (?,?,?)";
              String sqlscheduleresource = "INSERT INTO scheduleresource (ITBCRATE,SKILLS) VALUES (?,?)";
              try {
                   if (con.isClosed()) {
                        throw new IllegalStateException("error.unexpected");
                            // Insert into employee table
                   psemployee = con.prepareStatement(sqlemployee);
                   psemployee.setString(1,employee.getFirstName());
                   psemployee.setString(2,employee.getSurname());
                   psemployee.setString(3,employee.getGender());
                            // Insert into scheduleresource table
                   psscheduleresource = con.prepareStatement(sqlscheduleresource);
                   psscheduleresource.setDouble(1,employee.getItbcRate());
                   psscheduleresource.setString(2,employee.getSkills());
                   if (psemployee.executeUpdate() != 1 && psscheduleresource.executeUpdate() != 1) {
                        throw new CreateException("error.create.employee");
              } catch (SQLException e) {
                   e.printStackTrace();
                   throw new RuntimeException("error.unexpected");
              } finally {
                   try {
                        if (psemployee != null && psscheduleresource != null)
                             psemployee.close();
                             psscheduleresource.close();
                   } catch (SQLException e) {
                        e.printStackTrace();
                        throw new RuntimeException("error.unexpected");
         }

    Hi ,
    U can use
    set Auto Commit function here ..
    let it be false first
    and when u do with u r all queries ..
    make it true
    this function take boolean values
    i e helful when u want record to be inserted in all or not at all..
    Hope it helps

  • Insert into multiple table view

    I have a view with multiple table query and and INSTEAD OF trigger on the view that inserts into multiple tables. When I attempt to do a commit out of a ADF Creation Form, I get the following error: ORA-01779: cannot modify a column which maps to a non key-preserved table ORA-06512: at line 1.
    Has anyone had success inserting into multiple tables via a view that has more than one table?
    Thanks,
    Lisa

    Lisa,
    Sounds like your instead-of trigger may not be being called and you are trying to insert directly into the view.
    I did write a [url http://stegemanoracle.wordpress.com/2006/03/15/using-updatable-views-with-adf/]blog entry about using a view with instead-of triggers last year.
    John

  • Importing CSV files into Multiple Tables in One Database

     I have a web based solution using Microsoft SharePoint and SQL Server that is created to centralize dat collection and reporting of program metrics used in montly reviews.
    A person from each program enters dat manual or by pushing the data using automated data import tools. The user then is able to generate reports and provide presentations to their stakeholders.
    There are are programs that are located in US and 2 that are located in Japan. All, including programs in Japan use the MS Project with a plug-in tool that allows them to auto input data. When the user click the "Send To.." button, the data goes
    in to multiple tables in one database.
    Everything is set up exactly the same for every program; however, we have discovered becase of a firewall, along with some of the different settings that the MS Project has over in Japan, the 2 program users are not able to auto import their data.
    The suggestion is to have the program users export the MS Project file into a CSV and email it. I will then take it and convert the data, such as the dates and place them on a Network Drive. There will be 2 folders, one for each program.
    I feel it will be an easy process just to load the data from the Network Drive into the same tables that are created for auto import.
    My Concerns/Questions:
    1. Should I create 1 SSIS package or should there be 2, one for each program?
    2. US and Japan program users send their data once a month. The converted files are going to be saved in the location marked with a date (ex:201402). How can i have it to where SSIS will automatically load the data every time i place new files in the designated
    folders or when i update an exsisting file?
    Can you provide an example with your suggestion please?
    I greatly appreciate the assistance!
    Y_Tyler

    Hello Vikash,
    Thank you! This will help me get started.
    There will be 2 folders, one with files with Program A data and the other with files with Program B data. All will have the same fields, just coming from different programs. You stated that I will be able to to load both in one package. Would there be two
    paths since there will be two separate folders?
    Using the example you provided, i am confident that I can create the package using one path into one table but not sure how to get the files from 2 paths (if there is) into multiple tables.
    Can you help clarify this for me?
    Thank you!
    Y_Tyler

  • Insert data into multiple tables

    Hi all,
    I've a requirement where i need to insert data into multiple tables using PL/SQL procedure
    Procedure should have two parameters
    1. Table Name (parameter1)
    2. Data (parameter2)
    Based on these two parameters i need to insert data into table (parameter1) using data (parameter2)
    ex:
    Procedure insert_data (p_table  IN VARCHAR2
                          ,p_data   IN -- what should be the datatype?
    IS
    l_statement VARCHAR2(2000);
    BEGIN
    -- insert data into tables
    INSERT INTO p_table
    values (....);
    END insert_data;Thanks in advance!!

    BEDE wrote:
    Amen to that!
    So, I believe a better approach would be the following...
    Suppose you have N datafiles with the same structure, and you wish to insert into the database the data from all those files.
    For that, you should have a single table, named, say incoming_file_data, which should be structured more or less like below:
    create table incoming_file_data (
    filename varchar2(250) not null -- name of the file inserted from
    ,file_time timestamp -- timestamp when the data was inserted
    ,... -- the columns of meaningful data contained in the lines of those files
    );And you will insert the data from all those files in this table, having normally one transaction for each file processed, for otherwise, when shit happens, some file may only get to be partially inserted into the table...
    Maybe one good approach would be to create dynamically an external table for the file to be loaded, and then execute dynamically insert select into the table I said, so that you will have only one insert select for one file instead of using utl_file... RTM on that.If the file structures are the same, and it's just the filename that's changing, I would have a single external table definition, and use the alter table ... location ... statement (through execute immediate) to change the filename(s) as appropriate before querying the data. Of course that's not scalable if there are multiple users intenting to use this, but generally when we talk about importing multiple files, it's a one-user/one-off/once-a-day type of scenario, so multi-user isn't a consideration.

  • Inserting into multiple tables on one form using UIX

    We are developing an application using struts and UIX. We would like to be able to insert into three tables on one form(view). How can we accomplish this?

    This is more of an ADF question, you'll need to set up view object, than just drag it from the data control palette like normal.
    If it's not already set up as a view in the db (split into multiple tables), you'll need to create a view object that includes all the fields you want, based on multiple entity objects.

  • How to insert one table data into multiple tables by using procedure?

    How to insert one table data into multiple tables by using procedure?

    Below is the simple procedure. Try the below
    CREATE OR REPLACE PROCEDURE test_proc
    AS
    BEGIN
    INSERT ALL
      INTO emp_test1
      INTO emp_test2
      SELECT * FROM emp;
    END;
    If you want more examples you can refer below link
    multi-table inserts in oracle 9i
    Message was edited by: 000000

  • Howto import XML into Excel table ?

    Hi,
    I asked this before in the Excel forums but received the suggestion that I ask here instead.  The question precis : How to ungrey the "Append new data to existing XML lists" checkbox so I can select it when importing XML data into an Excel
    spreadsheet.
    I have a local server which provides data in XML form and need to import successive reloads of the XML page into successive lines in an Excel spreadsheet.  I found the Excel help page entitled "How to use XML in Excel 2003" at http://office.microsoft.com/en-gb/excel-help/how-to-use-xml-in-excel-2003-HA001101964.aspx?CTT=1&origin=EC001022986
    which was useful in so far as permitting me to import the data using the XML Source task pane and mapping the elements I need from the XML source to columns in the spreadsheet.
    In order to append successive lines from the XML source page, as I understand it from the link I quoted,  I need to change the XML Map properties to "Append new data to existing XML lists".  However this checkbox is greyed out in the
    XML Map properties dialog box so I can't select it.
    Any ideas how I can achieve my aims here ?
    Thanks in advance,
    Mike

    Hi Mike,
    Thank you for contacting Office IT Pro General Discussions Services. 
    From your description, I understand that you tried to import XML into Excel table. You selected “Use the XML Source
    task pane” when opening the XML file, then you tried to check the option in the
    Map Properties window: "Append new data to existing XML lists". 
    However, this option is grayed out. If there is any misunderstanding, please feel free to let me know.
    I have checked the issue on my side but could not reproduce this issue. I suggest download the sample XML file as suggested on the page and test the
    issue again:
    http://www.microsoft.com/downloads/details.aspx?FamilyId=B4BD3283-AD0B-408D-9CE7-AB9C3537BBBB&displaylang=en
    If the problem does not occur with the sample XML file, this issue might occur as there are some problems with the XML you were using.
    If the problem also occurs in with the sample XML file, this issue might be related to some third-party software conflicts. I suggest checking this
    issue by starting Excel in the safe mode.
    Start the Office program in safe mode
    ==============
    1.      
    Click Start, point to All Programs, and then point to
    Microsoft Office.
    2.       
    Press and hold the CTRL key, and then click
    Microsoft Excel.
    If the problem does not occur in the safe mode, this issue might be related to some third-party add-ins in the Excel program, we can try to disable
    them. Normally, you could do the following to disable the conflict add-ins in your Excel program:
    Disable add-ins
    Click
    Tools > Options > 
    Add-in, click Go button in the Manage:
    Com-in Add.
    Check if there are any add-ins,
    clear the checkbox to disable them.
    Close the Office program and
    restart it.
    Add one check back each time to the list of Add-In,
    restart the Office program, and repeat the above procedure. Once the issue reappears again, we can determine which add-in causes this problem and then disable it.
    Please take your time to try the suggestions and let me know the results at your earliest convenience. If anything is unclear or if there is anything
    I can do for you, please feel free to let me know.
    Best Regards,
    Sally Tang

  • Inserting data into multiple tables in jdbc

    I am doing on file to jdbc. Now I got a requirement to insert data into multiple tables on the receiver side. How can I do this ?

    Hi,
    you are going to insert data into 4 tables in a sequence one after another , I see three options.
    1) Stored procedure and 2) creating 4 statement data structure (one for each table)
    The third option is writing a SQL with join for the 4 tables and use action command = SQL_DML. Example as follows....
    Write SQL code and place it in access tag. Pass values for the columns using key tag...
    <stmt>
        <Customers action="SQL_DML">
          <access> UPDATE Customers SET CompanyName=u2019$NAME$u2019, Address=u2019$ADDRESS$' WHERE CustomerID='$KEYFIELD$u2019
          </access>
          <key>
            <NAME>name</NAME>
            <ADDRESS>add </ADDRESS>
            <KEYFIELD>1</KEYFIELD>
          </key>
        </Customers>
      </stmt>
    Refer this http://help.sap.com/saphelp_nwpi71/helpdata/en/44/7b7855fde93673e10000000a114a6b/content.htm
    Hope this helps ....

  • BizTalk 2013 R2 - Oracle client (Insert into Multiple tables) CompositE Transaction

    I know there is Composite Transaction of  inserting into multiple tables in SQL.
    Is there a way where we can have inserts into multiple table at once ? If yes, can anyone please provide step by step procedure to achieve this  
    MBH

    Here is a link on using Oracle DB w/ composite operations: 
    Performing Composite Operations on Oracle Database by Using BizTalk Server
    Rachit
    Please mark as answer or vote as helpful if my reply does

  • Loading XML files into multiple tables

    I've got XML like so...
    <?xml version="1.0" encoding="UTF-8"?>
    <MainTitle Version="1.0" Date="2009-01-11">
    <MainName>
    <ID1>A</ID1>
    <ID2>ABC</ID2>
    <ID3>ABC123</ID3>
    <Desc>Some text</Desc>
    <feature>f1</feature>
    <feature>f2</feature>
    <Category>
    <name>n1</name>
    <attribute>more stuff</attribute>
    </Category>
    <Category>
    <name>n2</name>
    <attribute>even more stuff</attribute>
    </Category>
    <Category>
    <name>n3</name>
    <attribute>different stuff</attribute>
    </Category>
    <Category>
    <name>n4</name>
    <attribute>More of the same<attribute>
    <attribute>But different still</attribute>
    <attribute>Even more different junk<attribute>
    </Category>
    </MainName>
    </MainTitle>
    Where each MainName instance in the file can have 0 or more ( unbounded ) Category and Feature tags and each Category instance can have multiple attribute tags. The file contains many thousands of MainName instances and has embedded a good mix of possible tags.
    I believe I can load this into 9i xmltype table or a 9i table with an xmltype column, then query the data to get it out...
    SQL> create table mytab (
    2 xmlraw XMLType
    3 );
    Table created.
    SQL>
    SQL> insert into mytab values ( sys.xmltype.createxml(
    2 '<?xml version="1.0" encoding="UTF-8"?>
    3 <MainTitle Version="1.0" Date="2009-01-11">
    4 <MainName>
    5 <ID1>A</ID1>
    6 <ID2>ABC</ID2>
    7 <ID3>ABC123</ID3>
    8 <Desc>Some text</Desc>
    9 <feature>f1</feature>
    10 <feature>f2</feature>
    11 <Category>
    12 <name>n1</name>
    13 <attribute>more stuff</attribute>
    14 </Category>
    15 <Category>
    16 <name>n2</name>
    17 <attribute>even more stuff</attribute>
    18 </Category>
    19 <Category>
    20 <name>n3</name>
    21 <attribute>different stuff</attribute>
    22 </Category>
    23 <Category>
    24 <name>n4</name>
    25 <attribute>More of the same</attribute>
    26 <attribute>But different still</attribute>
    27 <attribute>Even more different junk</attribute>
    28 </Category>
    29 </MainName>
    30 </MainTitle>')
    31 );
    1 row created.
    1 select
    2 extract(a.xmlraw,'/MainTitle/MainName/ID1/text()'),
    3 extract(a.xmlraw,'/MainTitle/MainName/ID2/text()'),
    4 extract(a.xmlraw,'/MainTitle/MainName/ID3/text()'),
    5 extract(a.xmlraw,'/MainTitle/MainName/Desc/text()'),
    6 extract(a.xmlraw,'/MainTitle/MainName/feature/text()'),
    7 extract(a.xmlraw,'/MainTitle/MainName/Category/text()'),
    8 extract(a.xmlraw,'/MainTitle/MainName/Category/name/text()'),
    9 extract(a.xmlraw,'/MainTitle/MainName/Category/attribute/text()')
    10* from mytab a
    SQL> /
    A
    ABC
    ABC123
    Some text
    f1f2
    n1n2n3n4
    more stuffeven more stuffdifferent stuffMore of the sameBut different stillEven
    more different junk
    This all works just fine, however, it's not quite what I need. For starters, the multiple tag data is concatenated and when I try to specifically query it out using a where clause I get ORA 22950. So, not sure how to deal with that.
    Is it possible to use sqlldr to get the 200MB XML file loaded into a table like that above?
    Now, given multiple "feature" and "category" data per "MainName", I need to use the SQL to dump the XML data into a set of tables built to model the structure of the XML...
    roughly..
    Main_Table (
    ID1 Varchar2(10)
    ID2 varchar2(10)
    ID3 varchar2(10)
    desc varchar2(100)
    Features_Table (
    ID1 varchar2(10)
    feature varchar2(100)
    Category_Table (
    ID1 varchar2(10)
    name varchar2(100)
    attribute varchar2(100)
    What are the groups recommendations here? Should I continue down this route or is there a better way?

    When I suggested the option to parse the XML in PL/SQL I was referring to pulling the data into PL/SQL and then performing all parsing activity against the PL/SQL copy and you don't need to make SQL calls.
    Here is a quick sample for parsing out all the Category/name elements from the XML once it is loaded into PL/SQL
    DECLARE
      l_index     PLS_INTEGER;
      l_category  XMLTYPE;
      l_db_row    XMLTYPE := XMLTYPE('<?xml version="1.0" encoding="UTF-8"?>
    <MainTitle Version="1.0" Date="2009-01-11">
       <MainName>
          <ID1>A</ID1>
          <ID2>ABC</ID2>
          <ID3>ABC123</ID3>
          <Desc>Some text</Desc>
          <feature>f1</feature>
          <feature>f2</feature>
          <Category>
             <name>n1</name>
             <attribute>more stuff</attribute>
          </Category>
          <Category>
             <name>n2</name>
             <attribute>even more stuff</attribute>
          </Category>
          <Category>
             <name>n3</name>
             <attribute>different stuff</attribute>
          </Category>
          <Category>
             <name>n4</name>
             <attribute>More of the same</attribute>
             <attribute>But different still</attribute>
                   <attribute>Even more different junk</attribute>
              </Category>
         </MainName>
    </MainTitle>');
    BEGIN
       l_index := 1;
       WHILE l_db_row.Existsnode('/MainTitle/MainName/Category[' ||
                                 To_Char(l_index) || ']') > 0
       LOOP
          l_category := l_db_row.Extract('/MainTitle/MainName/Category[' ||
                                           To_Char(l_index) || ']');
          dbms_output.put_line(l_category.extract('Category/name/text()').getStringVal());
          l_index := l_index + 1;
       END LOOP;
    END;You could repeat the WHILE loop to parse out the attribute column as well since it repeats. This is what Dave's post was showing and what I was referring to.
    Hint: If you are trying to use .extract to go after an optional node, you need to verify the node exists via existsNode first. If you don't you can get an "ORA-30625: method dispatch on NULL SELF argument is disallowed" error when trying to extract a non-existent node.

  • Loading xml into relational tables.

    I was wondering if anyone knows of a product/libraries which does the following:
    -Read data from a relational Database (multiple tables) and generate XML files based upon an XML Schema or DTD file?
    -Read XML files and load data into a relational Database.
    -Graphical Interface for performing the maps (perhaps based upon .xslt). ie.... Mapping of the XML Schema to Multiple Database Tables, Performing Joins etc...
    -Ability to connect to any type of Relational database (not just Oracle). Which rules out XML DB.

    This product does look to be ok, however it is missing a couple features that I would like the product to have.
    I would like this product to be able to insert/update data across multiple tables. Being able to do such things as generate foreign key relationships.
    It doesn't seem as though the XML being generated can be customized very easily. Some XML formats I deal with are very complex (such as X12/EDI).
    I would really like a graphical mapper.
    Here is a note from the doc:
    Storing XML Data Across Tables
    Currently the XML SQL Utility (XSU) can only store data in a single table. It maps a canonical representation of an XML document into any table or view. But there is a way to store XML with XSU across tables. You can do this using XSLT to transform any document into multiple documents and insert them separately. Another way is to define views over multiple tables (using object views if needed) and then do the insertions into the view. If the view is inherently non-updatable (because of complex joins), then you can use INSTEAD OF triggers over the views to do the inserts.
    This product looks really good, I was hoping that Oracle had something comparable:
    http://www.hitsw.com/products_services/xml_platform/allora.html

Maybe you are looking for