Inserting XML content into Database

Hallo
i´m new to Oracle.
i want to insert xml content into the database. for testing i installed the version 10g on a windowsxp computer.
i read the oracle xmldb developer´s guide. on page 3-4 ff. it is explained how i can insert content into the database. that´s how i did it (with isqlplus):
create table example1(key_column varchar2(10) primary key, xml_column xmltype)
-->works fine
create table example2 of xmltype
-->works fine
now i made a directory under c:\myXmlFilesForDb in WinXp
create directory xmldir as 'c:/myXmlFilesForDb in WinXp'
(also tried: create directory xmldir as 'c:\myXmlFilesForDb in WinXp')
--> in this directory is a file named: mydokument.xml
--> works fine
insert into example2 values(xmltype(bfilename('xmldir','mydokument.xml'), nls_charset_id('AL32UTF8')))
the following error message is displayed (in German):
ORA-22285: Verzeichnis oder Datei für FILEOPEN-Vorgang nicht vorhanden
ORA-06512: in "SYS.DBMS_LOB",Zeile 523
ORA-06512: in "SYS:XMLTYPE",Zeile 287
ORA-06512: in Zeile 1
whats wrong? can anybody help me please?
ohhh....
thank you very much
cu
George

Directory entries are case sensitive.
Select * From dba_directories to ensure you case is the same as you are using in your insert statement.
Are you using the same user? if not grant read on directory directoryname to username;
try to just select.
select dbms_lob.getLength(BFileName('directoryname','filename.xml'))
as length
from dual;

Similar Messages

  • Inserting new records into database table at runtime

    Hi all ,
    How to insert new records into database table at runtime on click update?
    Thanks.

    Hi Sasikala,
    Just for your understanding am giving a sample code snippet which you can use to read the contents of your Table UI element & save the data on to your database. Suppose you have a button up on pressing which you want to read the data from your screens table & save on to the database then you can proceed as shown below:
    1) Obtain the reference of your context node.
    2) Fetch all the data present in your table into an internal table using methods of if_wd_context_node
    3) Use your normal ABAP logic to update the database table with the data from your internal table
    In my example I have a node by name SFLIGHT_NODE and under this I have the desired attributes from SFLIGHT. Am displaying these in an editable table & the user would press up on a push button after making the necessary changes to the tables data. I would then need to obtain the tables information & save on to the database.
    data: node_sflight           type ref to if_wd_context_node,
            elem_sflight           type ref to if_wd_context_element,
            lt_elements            type WDR_CONTEXT_ELEMENT_SET,
           stru_sflight           type if_main=>element_sflight_node,
           it_flights             type if_main=>elements_sflight_node.
    "   navigate from <CONTEXT> to <SFLIGHT_NODE> via lead selection
        node_sflight_node = wd_context->get_child_node( name = 'SFLIGHT_NODE'  ).
       lt_elements = node_sflight->get_elements( ).
    "   Get all the rows from the table for saving on to the database
        loop at lt_elements into elem_sflight.
          elem_sflight->get_static_attributes( importing static_attributes = stru_sflight ).
          append stru_sflight to it_flights.
        endloop.
    " Finally save the entries on to the database
        modify ZSFLIGHT99 from table it_flights.
        if sy-subrc eq 0.
    endif.
    However a word of caution here.... SAP doesn't ever recommend directly modifying the database through an SQL query. You would preferably make use of a BAPI for the same. Try go through Thomas Jung's comments in [here|modify the data base table which is comming dynamiclly;.
    Regards,
    Uday

  • Steps to insert xml data into oracle

    Please give me next steps to insert xml data into oracle 9i:
    i've been doing this steps :
    1. create folder in oracle port:8080
    2. copy xsd into folder
    3. register schema
    4. Give me next step...
    5.
    6.
    Thanks

    this is my complete xmlschema
    <?xml version = "1.0" encoding = "UTF-8"?>
    <xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema">
         <xs:element name = "A3A8Vers" type = "xs:string"/>
         <xs:element name = "F1F5Vers" type = "xs:string">
         </xs:element>
         <xs:element name = "sequence" type = "xs:string">
         </xs:element>
         <xs:element name = "amf" type = "xs:string">
         </xs:element>
         <xs:element name = "trnsKeyNumber" type = "xs:string">
         </xs:element>
         <xs:element name = "mac" type = "xs:string">
         </xs:element>
         <xs:element name = "encryptionKey" type = "xs:string">
         </xs:element>
         <xs:element name = "signature" type = "xs:string">
         </xs:element>
         <xs:element name = "signer">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref = "entityNumber"/>
                        <xs:element ref = "keyNumber"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name = "entityNumber" type = "xs:string">
         </xs:element>
         <xs:element name = "keyNumber" type = "xs:string">
         </xs:element>
         <xs:element name = "pblKey">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref = "entityNumber"/>
                        <xs:element ref = "entityRole"/>
                        <xs:element ref = "keyNumber"/>
                        <xs:element ref = "publicKeyVal"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name = "ntrTime" type = "xs:string">
         </xs:element>
         <xs:element name = "deActionTime" type = "xs:string">
         </xs:element>
         <xs:element name = "actionTime" type = "xs:string">
         </xs:element>
         <xs:element name = "entityRole">
              <xs:complexType>
                   <xs:attribute name = "role" default = "INVALID">
                        <xs:simpleType>
                             <xs:restriction base = "xs:NMTOKEN">
                                  <xs:enumeration value = "TKD"/>
                                  <xs:enumeration value = "SKD"/>
                                  <xs:enumeration value = "INVALID"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:attribute>
              </xs:complexType>
         </xs:element>
         <xs:element name = "publicKeyVal">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref = "exponent"/>
                        <xs:element ref = "mod"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name = "exponent" type = "xs:string">
         </xs:element>
         <xs:element name = "mod" type = "xs:string">
         </xs:element>
         <xs:element name = "encriptionTransKey" type = "xs:string">
         </xs:element>
         <xs:element name = "keyType" type = "xs:string">
         </xs:element>
    </xs:schema>.
    I use command to create table :
    create table elements of xmltype
    xmlschema "http://192.168.1.1:8080/test.xsd"
    element "publicKey"
    . But why the result,table as object type. so i cant use command "desc <table_name>;"

  • Inserting blob data into database

    Hello everybody,
    I need insert blob data into database. that data i need to get from form
    can i use request.getParameter(""); for getting that file.
    Plz help how to get data from form to servlet and through callablestatement i need to insert into database.
    regards,
    Anil

    Hi,
    1) first create a form with file element
    first.jsp
    <form action="GetData" enctype="multipart/form-data" method="post">
    <input type="file" name="datafile" size="40">
    <input type="submit" value="Send">
    <input type="reset" name="Reset" value="Cancel">
    </form>
    GetData.java
    // servlet file
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    res.setContentType("text/html");
    PrintWriter out = response.getWriter();
    try {
    System.setProperty( "jdbc.drivers", "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
    Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver" );
    con = DriverManager.getConnection( "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=JAVATEAM;SelectMethod=cursor;User=sa;Password=urpassword" );
    PreparedStatement pst = con.prepareStatement("insert into uploads(binaryfile) values(?)");
    FileInputStream fis=new FileInputStream(request.getParameter ( "datafile" ) );
    byte[] b= new byte[fis.available()+1];
    fis.read(b);
    pst.setBytes(1,b);
    pst.executeUpdate();
    pst.close();
    con.close();
    catch(SQLException e)
    out.println ( e);
    catch (ClassNotFoundException e)
    out.println( e );
    }Here in doPost(), i create preparedstatement,
    now you to create one procedure for insert
    and by using callable statement you just call that procedure and pass this byte b as arguments,
    now its in your hands
    my idea is over.

  • How to eliminate inserting  Duplicate rows into database using JDBC Adapter

    File->Xi->JDBC
    In above Scenario if the file has two rows their values are identical, then how can we eliminated inserting  Duplicate rows into database using JDBC Adapter

    Database is a consumer of a SERVICE (SOA!!!!!!).
    Database plays a business system role here!!!!
    Mapping is part of an ESB service
    Adaptor is a technology adapted to ESB framework to support specific protocol.
    ESB accomplish ESB duties such as transformation, translation, routing. Routing use a protocol accepted by the consumer. In a JDBC consumer it is JDBC protocol and hence it a JDBC adaptor.
    There is clear separation on responsibilities among business system and ESB. ESB do not participate in business decision or try to get into business system data layer.
    So who ever are asking people to check duplicate check as part of mapping (an ESB service) may not understand integration practice.
    Please use an adaptor module which will execute the duplicate check with business system in a plug and play approach and separate that from ESB service so that people can build integration using AGILE approach.
    Thanks

  • Inserting HTML content into an animated DIV

    Can you, and if so how, insert HTLM content into an EGDE animated Div box? Specificaly an HTML table?  I can get the html code in the box but it won't read/render it as html code. In flash you can tell the program that the contents of the box is html code and it will read it as such but I don't see any way to do that here. I've tried several ways and I can get the code to display in the box but it won't render the code instruction in the boxCan it be done ??
    Thanks
    joel

    Hi,
    1) Your json file is not valid.
    You can copy and paste your datas here: http://jsonlint.com/
    Red commas must be deleted.
          "player": [
                "image": "images/player1.jpg",  //this is the URL I want to retrive
               "name": "player1",
                "image": "images/player2.jpg",
                "name": "player2", 
                "image": "images/player3.jpg",
                "name": "player3", 
                "image": "images/player4.jpg",
                "name": "player4",
    2)An example from http://docs.jquery.com/Ajax/jQuery.getJSON:
    3) compositionReady Tests.
    On compositionReady, i write:
    var profiles = {
                   "player": [
                        "image": "images/player1.jpg",
                        "name": "player1",
                         "image": "images/player2.jpg",
                         "name": "player2", 
                         "image": "images/player3.jpg",
                         "name": "player3", 
                         "image": "images/player4.jpg",
                         "name": "player4",
    console.log(profiles.player[1].image); // this line returns: "images/player2.jpg"
    Note: i deleted the first "[" and the last "]".

  • Insert multiple records into database through internal table

    Hi
      please help me how to insert multiple records into database through internal table

    Hi,
    Welcome to SCN.
    Press F1 on INSERT statement and you will teh syntax as well the docu for the same.

  • Must insert new content into body element-

    I'm using 1.4.0_01-b03 with JEditPane and the HTMLToolKit. Up until this afternoon everything was working fine. Now randomly, I am getting the following stack trace. I am loading using setPage(URL url) to set the contents. The contents of the page being load have not changed.
    Any clues?
    java.lang.RuntimeException: Must insert new content into body element-
         at javax.swing.text.html.HTMLDocument$HTMLReader.generateEndsSpecsForMidInsert(HTMLDocument.java:1878)
         at javax.swing.text.html.HTMLDocument$HTMLReader.<init>(HTMLDocument.java:1854)
         at javax.swing.text.html.HTMLDocument$HTMLReader.<init>(HTMLDocument.java:1729)
         at javax.swing.text.html.HTMLDocument$HTMLReader.<init>(HTMLDocument.java:1724)
         at javax.swing.text.html.HTMLDocument.getReader(HTMLDocument.java:125)
         at javax.swing.text.html.HTMLEditorKit.read(HTMLEditorKit.java:227)
         at javax.swing.JEditorPane.read(JEditorPane.java:504)
         at javax.swing.JEditorPane.read(JEditorPane.java:522)
         at javax.swing.JEditorPane$PageLoader.run(JEditorPane.java:551)

    I ran into the same problem. I wanted to display programmatically created content which had images loaded from the jar file. I found that the following works, but I don't know why other ways fail.
    URL url = getClass().getResource("page.html");
    InputStream pageInput = getClass().getResourceAsStream("page.html");
    // Read and modify page.html into variable "content"
    html = new JEditorPane("text/html", "");
    ((HTMLDocument) html.getDocument()).setBase(url);
    html.setText(content);

  • Loading XML files into Database table

    Loading XML files into Database table
    Hi I have some XML files say 100 files in a virtual directory created using &quot;Create or replace directory command&quot; and those files need to be loaded into a table having a column of XMLTYPE. 1)How to load that using Oracle provided procedures/packages

    Check out the Oracle XDB Developer's Guide, Chapter 3. There is an example of using BFileName function to load the xml files from a directory object created using create or replace directory. It works really well.
    Ben

  • How to insert large xml data into database tables.

    Hi all,
    iam new to xml. i want to insert data in xml file to my database tables.but the xml file size is very large. performance is also one of the issue. can anybody please tell me the procedure to take xml file from the server and insert into my database tables.
    Thanks in advance

    Unfortunately posting very generic questions like this in the forum tends not to be very productive for you, me or the other people who read the forum. It really helps everyone if you take a little time to review existing posts and their answers before starting new threads which replicate subjects that have already been discussed extensively in previous threads. This allows you to ask more sensible questions (eg, I'm using this approach and encountering this problem) rather than extremely generic questions that you can answer yourself by spending a little time reviewing existings posts or using the forum's search feature.
    Also in future your might want to try being a little more specific before posting questions
    Eg Define "very large". I know of customers who thing very large is 100K, and customers who think 4G is medium. I cannot tell from your post what size your files are.
    What is the content of the file. Is it going to be loaded into a single record, or a a single table, or will it need to be loaded into multiple records in a single table or multiple records in multiple tables ?
    Do you really need to load the data into exsiting relational tables or could your application work with relational views of the XML Content.
    Finally which release of the database are you working with.
    Define performance. Is it reasonable to expect to process this kind of document on this machine (Make, memory, #number of CPUs, CPU Speed, number of discs) in this period of time.
    WRT to your original question. If you take a few minutes to search this forum you will find a very large number of threads with very similar titles to yours. These theads document a number of different approaches that can be used to solve this problem.
    I suggest you start by looking for threads that cover topics like DBMS_XMLSTORE, XMLTable(), Relational Views of XML content, loading XML content in relational tables.

  • Exception when inserting a XML document into database

    Hello.
    I'm trying to insert the content of a XML document into a database. The problem consists on the exception that is raised when a FK in the XML is not in the database as a PK
    How can i catch these exceptions and continuing inserting the rest of the data
    Thanks in advance ...

    I really hope for you this wasn't a production database, as mentioned in the URL, it has been some years ago for me fiddling around this which was btw a supported metalink workaround ONCE (during my Oracle 7 days), but now, I wouldn't be surprised if you now have mixed NLS content in your tables/database and more or less "corrupted" your content.
    The initial issue was probably a client one.
    BTW
    I actually hope it was a production database, maybe then you would learn that way, that you SHOULD NEVER EVER UPDATE DATABASE BASE TABLES directly...
    ...unless (the only exception) you want to learn something about the internals and don't care that your TEST database gets corrupted....

  • Insert XML file into Relational database model - no XMLTYPE!

    Dear all,
    How can I store a known complex XML file into an existing relational database WITHOUT using xmltypes in the database ?
    I read the article on DBMS_XMLSTORE. DBMS_XMLSTORE indeed partially bridges the gap between XML and RDBMS to a certain extent, namely for simply structured XML (canonical structure) and simple tables.
    However, when the XML structure will become arbitrary and rapidly evolving, surely there must be a way to map XML to a relational model more flexibly.
    We work in a java/Oracle10 environment that receives very large XML documents from an independent data management source. These files comply with an XML schema. That is all we know. Still, all these data must be inserted/updated daily in an existing relational model. Quite an assignment isn't it ?
    The database does and will not contain XMLTYPES, only plain RDBMS tables.
    Are you aware of a framework/product or tool to do what DBMS_XMLSTORE does but with any format of XML file ? If not, I am doomed.
    Cheers.
    Luc.
    Edited by: user6693852 on Jan 13, 2009 7:02 AM

    In case you decide to follow my advice, here's a simple example showing how to do this.. (Note the XMLTable syntax is the preferred approach in 10gr2 and later..
    SQL> spool testase.log
    SQL> --
    SQL> connect / as sysdba
    Connected.
    SQL> --
    SQL> set define on
    SQL> set timing on
    SQL> --
    SQL> define USERNAME = XDBTEST
    SQL> --
    SQL> def PASSWORD = XDBTEST
    SQL> --
    SQL> def USER_TABLESPACE = USERS
    SQL> --
    SQL> def TEMP_TABLESPACE = TEMP
    SQL> --
    SQL> drop user &USERNAME cascade
      2  /
    old   1: drop user &USERNAME cascade
    new   1: drop user XDBTEST cascade
    User dropped.
    Elapsed: 00:00:00.59
    SQL> grant create any directory, drop any directory, connect, resource, alter session, create view to &USERNAME identified by &PASS
    ORD
      2  /
    old   1: grant create any directory, drop any directory, connect, resource, alter session, create view to &USERNAME identified by &
    ASSWORD
    new   1: grant create any directory, drop any directory, connect, resource, alter session, create view to XDBTEST identified by XDB
    EST
    Grant succeeded.
    Elapsed: 00:00:00.01
    SQL> alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
      2  /
    old   1: alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
    new   1: alter user XDBTEST default tablespace USERS temporary tablespace TEMP
    User altered.
    Elapsed: 00:00:00.00
    SQL> connect &USERNAME/&PASSWORD
    Connected.
    SQL> --
    SQL> var SCHEMAURL varchar2(256)
    SQL> var XMLSCHEMA CLOB
    SQL> --
    SQL> set define off
    SQL> --
    SQL> begin
      2    :SCHEMAURL := 'http://xmlns.example.com/askTom/TransactionList.xsd';
      3    :XMLSCHEMA :=
      4  '<?xml version="1.0" encoding="UTF-8"?>
      5  <!--W3C Schema generated by XMLSpy v2008 rel. 2 sp2 (http://www.altova.com)-->
      6  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
      7     <xs:element name="TransactionList" type="transactionListType" xdb:defaultTable="LOCAL_TABLE"/>
      8     <xs:complexType name="transactionListType"  xdb:maintainDOM="false" xdb:SQLType="TRANSACTION_LIST_T">
      9             <xs:sequence>
    10                     <xs:element name="Transaction" type="transactionType" maxOccurs="unbounded" xdb:SQLCollType="TRANSACTION_V"
    >
    11             </xs:sequence>
    12     </xs:complexType>
    13     <xs:complexType name="transactionType" xdb:maintainDOM="false"  xdb:SQLType="TRANSACTION_T">
    14             <xs:sequence>
    15                     <xs:element name="TradeVersion" type="xs:integer"/>
    16                     <xs:element name="TransactionId" type="xs:integer"/>
    17                     <xs:element name="Leg" type="legType" maxOccurs="unbounded" xdb:SQLCollType="LEG_V"/>
    18             </xs:sequence>
    19             <xs:attribute name="id" type="xs:integer" use="required"/>
    20     </xs:complexType>
    21     <xs:complexType name="paymentType"  xdb:maintainDOM="false" xdb:SQLType="PAYMENT_T">
    22             <xs:sequence>
    23                     <xs:element name="StartDate" type="xs:date"/>
    24                     <xs:element name="Value" type="xs:integer"/>
    25             </xs:sequence>
    26             <xs:attribute name="id" type="xs:integer" use="required"/>
    27     </xs:complexType>
    28     <xs:complexType name="legType"  xdb:maintainDOM="false"  xdb:SQLType="LEG_T">
    29             <xs:sequence>
    30                     <xs:element name="LegNumber" type="xs:integer"/>
    31                     <xs:element name="Basis" type="xs:integer"/>
    32                     <xs:element name="FixedRate" type="xs:integer"/>
    33                     <xs:element name="Payment" type="paymentType" maxOccurs="unbounded"  xdb:SQLCollType="PAYMENT_V"/>
    34             </xs:sequence>
    35             <xs:attribute name="id" type="xs:integer" use="required"/>
    36     </xs:complexType>
    37  </xs:schema>';
    38  end;
    39  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    SQL> set define on
    SQL> --
    SQL> declare
      2    res boolean;
      3    xmlSchema xmlType := xmlType(:XMLSCHEMA);
      4  begin
      5    dbms_xmlschema.registerSchema
      6    (
      7      schemaurl => :schemaURL,
      8      schemadoc => xmlSchema,
      9      local     => TRUE,
    10      genTypes  => TRUE,
    11      genBean   => FALSE,
    12      genTables => TRUE,
    13      ENABLEHIERARCHY => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
    14    );
    15  end;
    16  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.26
    SQL> desc LOCAL_TABLE
    Name                                                                   Null?    Type
    TABLE of SYS.XMLTYPE(XMLSchema "http://xmlns.example.com/askTom/TransactionList.xsd" Element "TransactionList") STORAGE Object-rela
    ional TYPE "TRANSACTION_LIST_T"
    SQL> --
    SQL> create or replace VIEW TRAN_VIEW
      2  as
      3  select
      4    extractvalue(x.column_value,'/Transaction/TradeVersion/text()') tradeversion,
      5    extractvalue(x.column_value,'/Transaction//text()') transactionid
      6  from
      7    local_table,
      8    table(xmlsequence(extract(OBJECT_VALUE,'/TransactionList/Transaction'))) x
      9  /
    View created.
    Elapsed: 00:00:00.01
    SQL> create or replace VIEW TRAN_LEG_VIEW
      2  as
      3  select
      4    extractvalue(x.column_value,'/Transaction/TransactionId/text()') transactionid,
      5    extractvalue(y.column_value,'/Leg/Basis/text()') leg_basis,
      6    extractValue(y.column_value,'/Leg/FixedRate/text()') leg_fixedrate
      7  from
      8    local_table,
      9    table(xmlsequence(extract(OBJECT_VALUE,'/TransactionList/Transaction'))) x,
    10    table(xmlsequence(extract(x.column_value,'/Transaction/Leg'))) y
    11  /
    View created.
    Elapsed: 00:00:00.01
    SQL> create or replace VIEW TRAN_LEG_PAY_VIEW
      2  as
      3  select
      4    extractvalue(x.column_value,'/Transaction/TransactionId/text()') transactionid,
      5    extractvalue(y.column_value,'/Leg/LegNumber/text()') leg_legnumber,
      6    extractvalue(z.column_value,'/Payment/StartDate/text()') pay_startdate,
      7    extractValue(z.column_value,'/Payment/Value/text()') pay_value
      8  from
      9    local_table,
    10    table(xmlsequence(extract(OBJECT_VALUE,'/TransactionList/Transaction'))) x,
    11    table(xmlsequence(extract(x.column_value,'/Transaction/Leg'))) y,
    12    table(xmlsequence(extract(y.column_value,'/Leg/Payment'))) z
    13  /
    View created.
    Elapsed: 00:00:00.03
    SQL> desc TRAN_VIEW
    Name                                                                   Null?    Type
    TRADEVERSION                                                                    NUMBER(38)
    TRANSACTIONID                                                                   VARCHAR2(4000)
    SQL> --
    SQL> desc TRAN_LEG_VIEW
    Name                                                                   Null?    Type
    TRANSACTIONID                                                                   NUMBER(38)
    LEG_BASIS                                                                       NUMBER(38)
    LEG_FIXEDRATE                                                                   NUMBER(38)
    SQL> --
    SQL> desc TRAN_LEG_PAY_VIEW
    Name                                                                   Null?    Type
    TRANSACTIONID                                                                   NUMBER(38)
    LEG_LEGNUMBER                                                                   NUMBER(38)
    PAY_STARTDATE                                                                   DATE
    PAY_VALUE                                                                       NUMBER(38)
    SQL> --
    SQL> create or replace VIEW TRAN_VIEW_XMLTABLE
      2  as
      3  select t.*
      4    from LOCAL_TABLE,
      5         XMLTable
      6         (
      7            '/TransactionList/Transaction'
      8            passing OBJECT_VALUE
      9            columns
    10            TRADE_VERSION  NUMBER(4) path 'TradeVersion/text()',
    11            TRANSACTION_ID NUMBER(4) path 'TransactionId/text()'
    12         ) t
    13  /
    View created.
    Elapsed: 00:00:00.01
    SQL> create or replace VIEW TRAN_LEG_VIEW_XMLTABLE
      2  as
      3  select t.TRANSACTION_ID, L.*
      4    from LOCAL_TABLE,
      5         XMLTable
      6         (
      7            '/TransactionList/Transaction'
      8            passing OBJECT_VALUE
      9            columns
    10            TRANSACTION_ID NUMBER(4) path 'TransactionId/text()',
    11            LEG            XMLType   path 'Leg'
    12         ) t,
    13         XMLTABLE
    14         (
    15           '/Leg'
    16           passing LEG
    17           columns
    18           LEG_NUMBER     NUMBER(4) path 'LegNumber/text()',
    19           LEG_BASIS      NUMBER(4) path 'Basis/text()',
    20           LEG_FIXED_RATE NUMBER(4) path 'FixedRate/text()'
    21         ) l
    22  /
    View created.
    Elapsed: 00:00:00.01
    SQL> create or replace VIEW TRAN_LEG_PAY_VIEW_XMLTABLE
      2  as
      3  select TRANSACTION_ID, L.LEG_NUMBER, P.*
      4    from LOCAL_TABLE,
      5         XMLTable
      6         (
      7            '/TransactionList/Transaction'
      8            passing OBJECT_VALUE
      9            columns
    10            TRANSACTION_ID NUMBER(4) path 'TransactionId/text()',
    11            LEG            XMLType   path 'Leg'
    12         ) t,
    13         XMLTABLE
    14         (
    15           '/Leg'
    16           passing LEG
    17           columns
    18           LEG_NUMBER     NUMBER(4) path 'LegNumber/text()',
    19           PAYMENT        XMLType   path 'Payment'
    20         ) L,
    21         XMLTABLE
    22         (
    23           '/Payment'
    24           passing PAYMENT
    25           columns
    26           PAY_START_DATE     DATE      path 'StartDate/text()',
    27           PAY_VALUE          NUMBER(4) path 'Value/text()'
    28         ) p
    29  /
    View created.
    Elapsed: 00:00:00.03
    SQL> desc TRAN_VIEW_XMLTABLE
    Name                                                                   Null?    Type
    TRADE_VERSION                                                                   NUMBER(4)
    TRANSACTION_ID                                                                  NUMBER(4)
    SQL> --
    SQL> desc TRAN_LEG_VIEW_XMLTABLE
    Name                                                                   Null?    Type
    TRANSACTION_ID                                                                  NUMBER(4)
    LEG_NUMBER                                                                      NUMBER(4)
    LEG_BASIS                                                                       NUMBER(4)
    LEG_FIXED_RATE                                                                  NUMBER(4)
    SQL> --
    SQL> desc TRAN_LEG_PAY_VIEW_XMLTABLE
    Name                                                                   Null?    Type
    TRANSACTION_ID                                                                  NUMBER(4)
    LEG_NUMBER                                                                      NUMBER(4)
    PAY_START_DATE                                                                  DATE
    PAY_VALUE                                                                       NUMBER(4)
    SQL> --
    SQL> set long 10000 pages 100 lines 128
    SQL> set timing on
    SQL> set autotrace on explain
    SQL> set heading on feedback on
    SQL> --
    SQL> VAR DOC1 CLOB
    SQL> VAR DOC2 CLOB
    SQL> --
    SQL> begin
      2    :DOC1 :=
      3  '<TransactionList>
      4    <Transaction id="1">
      5      <TradeVersion>1</TradeVersion>
      6      <TransactionId>1</TransactionId>
      7      <Leg id="1">
      8        <LegNumber>1</LegNumber>
      9        <Basis>1</Basis>
    10        <FixedRate>1</FixedRate>
    11        <Payment id="1">
    12          <StartDate>2000-01-01</StartDate>
    13          <Value>1</Value>
    14        </Payment>
    15        <Payment id="2">
    16          <StartDate>2000-01-02</StartDate>
    17          <Value>2</Value>
    18        </Payment>
    19      </Leg>
    20      <Leg id="2">
    21        <LegNumber>2</LegNumber>
    22        <Basis>2</Basis>
    23        <FixedRate>2</FixedRate>
    24        <Payment id="1">
    25          <StartDate>2000-02-01</StartDate>
    26          <Value>10</Value>
    27        </Payment>
    28        <Payment id="2">
    29          <StartDate>2000-02-02</StartDate>
    30          <Value>20</Value>
    31        </Payment>
    32      </Leg>
    33    </Transaction>
    34    <Transaction id="2">
    35      <TradeVersion>2</TradeVersion>
    36      <TransactionId>2</TransactionId>
    37      <Leg id="1">
    38        <LegNumber>21</LegNumber>
    39        <Basis>21</Basis>
    40        <FixedRate>21</FixedRate>
    41        <Payment id="1">
    42          <StartDate>2002-01-01</StartDate>
    43          <Value>21</Value>
    44        </Payment>
    45        <Payment id="2">
    46          <StartDate>2002-01-02</StartDate>
    47          <Value>22</Value>
    48        </Payment>
    49      </Leg>
    50      <Leg id="22">
    51        <LegNumber>22</LegNumber>
    52        <Basis>22</Basis>
    53        <FixedRate>22</FixedRate>
    54        <Payment id="21">
    55          <StartDate>2002-02-01</StartDate>
    56          <Value>210</Value>
    57        </Payment>
    58        <Payment id="22">
    59          <StartDate>2002-02-02</StartDate>
    60          <Value>220</Value>
    61        </Payment>
    62      </Leg>
    63    </Transaction>
    64  </TransactionList>';
    65    :DOC2 :=
    66  '<TransactionList>
    67    <Transaction id="31">
    68      <TradeVersion>31</TradeVersion>
    69      <TransactionId>31</TransactionId>
    70      <Leg id="31">
    71        <LegNumber>31</LegNumber>
    72        <Basis>31</Basis>
    73        <FixedRate>31</FixedRate>
    74        <Payment id="31">
    75          <StartDate>3000-01-01</StartDate>
    76          <Value>31</Value>
    77        </Payment>
    78      </Leg>
    79    </Transaction>
    80  </TransactionList>';
    81  end;
    82  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.01
    SQL> insert into LOCAL_TABLE values ( xmltype(:DOC1))
      2  /
    1 row created.
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 1
    | Id  | Operation                | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | INSERT STATEMENT         |             |     1 |   100 |     1   (0)| 00:00:01 |
    |   1 |  LOAD TABLE CONVENTIONAL | LOCAL_TABLE |       |       |            |          |
    SQL> insert into LOCAL_TABLE values ( xmltype(:DOC2))
      2  /
    1 row created.
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 1
    | Id  | Operation                | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | INSERT STATEMENT         |             |     1 |   100 |     1   (0)| 00:00:01 |
    |   1 |  LOAD TABLE CONVENTIONAL | LOCAL_TABLE |       |       |            |          |
    SQL> select * from TRAN_VIEW_XMLTABLE
      2  /
    TRADE_VERSION TRANSACTION_ID
                1              1
                2              2
               31             31
    3 rows selected.
    Elapsed: 00:00:00.03
    Execution Plan
    Plan hash value: 650975545
    | Id  | Operation          | Name                           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |                                |     3 |   168 |     3   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS      |                                |     3 |   168 |     3   (0)| 00:00:01 |
    |*  2 |   TABLE ACCESS FULL| SYS_NTGgl+TKyhQnWoFRSrCxeX9g== |     3 |   138 |     3   (0)| 00:00:01 |
    |*  3 |   INDEX UNIQUE SCAN| SYS_C0010174                   |     1 |    10 |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter("SYS_NC_TYPEID$" IS NOT NULL)
       3 - access("NESTED_TABLE_ID"="LOCAL_TABLE"."SYS_NC0000800009$")
    Note
       - dynamic sampling used for this statement
    SQL> select * from TRAN_LEG_VIEW_XMLTABLE
      2  /
    TRANSACTION_ID LEG_NUMBER  LEG_BASIS LEG_FIXED_RATE
                 1          1          1              1
                 1          2          2              2
                 2         21         21             21
                 2         22         22             22
                31         31         31             31
    5 rows selected.
    Elapsed: 00:00:00.04
    Execution Plan
    Plan hash value: 1273661583
    | Id  | Operation           | Name                           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |                                |     5 |   560 |     7  (15)| 00:00:01 |
    |*  1 |  HASH JOIN          |                                |     5 |   560 |     7  (15)| 00:00:01 |
    |   2 |   NESTED LOOPS      |                                |     3 |   159 |     3   (0)| 00:00:01 |
    |*  3 |    TABLE ACCESS FULL| SYS_NTGgl+TKyhQnWoFRSrCxeX9g== |     3 |   129 |     3   (0)| 00:00:01 |
    |*  4 |    INDEX UNIQUE SCAN| SYS_C0010174                   |     1 |    10 |     0   (0)| 00:00:01 |
    |*  5 |   TABLE ACCESS FULL | SYS_NTUmyermF/S721C/2UXo40Uw== |     5 |   295 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - access("SYS_ALIAS_1"."NESTED_TABLE_ID"="SYS_ALIAS_0"."SYS_NC0000800009$")
       3 - filter("SYS_NC_TYPEID$" IS NOT NULL)
       4 - access("NESTED_TABLE_ID"="LOCAL_TABLE"."SYS_NC0000800009$")
       5 - filter("SYS_NC_TYPEID$" IS NOT NULL)
    Note
       - dynamic sampling used for this statement
    SQL> select * from TRAN_LEG_PAY_VIEW_XMLTABLE
      2  /
    TRANSACTION_ID LEG_NUMBER PAY_START  PAY_VALUE
                 1          1 01-JAN-00          1
                 1          1 02-JAN-00          2
                 1          2 01-FEB-00         10
                 1          2 02-FEB-00         20
                 2         21 01-JAN-02         21
                 2         21 02-JAN-02         22
                 2         22 01-FEB-02        210
                 2         22 02-FEB-02        220
                31         31 01-JAN-00         31
    9 rows selected.
    Elapsed: 00:00:00.07
    Execution Plan
    Plan hash value: 4004907785
    | Id  | Operation            | Name                           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |                                |     9 |  1242 |    10  (10)| 00:00:01 |
    |*  1 |  HASH JOIN           |                                |     9 |  1242 |    10  (10)| 00:00:01 |
    |*  2 |   HASH JOIN          |                                |     5 |   480 |     7  (15)| 00:00:01 |
    |   3 |    NESTED LOOPS      |                                |     3 |   159 |     3   (0)| 00:00:01 |
    |*  4 |     TABLE ACCESS FULL| SYS_NTGgl+TKyhQnWoFRSrCxeX9g== |     3 |   129 |     3   (0)| 00:00:01 |
    |*  5 |     INDEX UNIQUE SCAN| SYS_C0010174                   |     1 |    10 |     0   (0)| 00:00:01 |
    |*  6 |    TABLE ACCESS FULL | SYS_NTUmyermF/S721C/2UXo40Uw== |     5 |   215 |     3   (0)| 00:00:01 |
    |*  7 |   TABLE ACCESS FULL  | SYS_NTelW4ZRtKS+WKqCaXhsHnNQ== |     9 |   378 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - access("NESTED_TABLE_ID"="SYS_ALIAS_1"."SYS_NC0000900010$")
       2 - access("SYS_ALIAS_1"."NESTED_TABLE_ID"="SYS_ALIAS_0"."SYS_NC0000800009$")
       4 - filter("SYS_NC_TYPEID$" IS NOT NULL)
       5 - access("NESTED_TABLE_ID"="LOCAL_TABLE"."SYS_NC0000800009$")
       6 - filter("SYS_NC_TYPEID$" IS NOT NULL)
       7 - filter("SYS_NC_TYPEID$" IS NOT NULL)
    Note
       - dynamic sampling used for this statement
    SQL>Out of interest why are you so against using XMLType...
    Edited by: mdrake on Jan 13, 2009 8:25 AM

  • Insert XML file into Relational database model without using XMLTYPE tables

    Dear all,
    How can I store a known complex XML file into an existing relational database WITHOUT using xmltypes in the database ?
    I read the article on DBMS_XMLSTORE. DBMS_XMLSTORE indeed partially bridges the gap between XML and RDBMS to a certain extent, namely for simply structured XML (canonical structure) and simple tables.
    However, when the XML structure will become arbitrary and rapidly evolving, surely there must be a way to map XML to a relational model more flexibly.
    We work in a java/Oracle10 environment that receives very large XML documents from an independent data management source. These files comply with an XML schema. That is all we know. Still, all these data must be inserted/updated daily in an existing relational model. Quite an assignment isn't it ?
    The database does and will not contain XMLTYPES, only plain RDBMS tables.
    Are you aware of a framework/product or tool to do what DBMS_XMLSTORE does but with any format of XML file ? If not, I am doomed.
    Constraints : Input via XML files defined by third party
    Storage : relational database model with hundreds of tables and thousands of existing queries that can not be touched. The model must not be altered.
    Target : get this XML into the database on a daily basis via an automated process.
    Cheers.
    Luc.

    Luc,
    your Doomed !
    If you would try something like DBMS_XMLSTORE, you probably would be into serious performance problems in your case, very fast, and it would be very difficult to manage.
    If you would use a little bit of XMLType stuff, you would be able to shred the data into the relational model very fast and controlable. Take it from me, I am one of those old geezers like Mr. Tom Kyte way beyond 40 years (still joking). No seriously. I started out as a classical PL/SQL, Forms Guy that switched after two years to become a "DBA 1.0" and Mr Codd and Mr Date were for years my biggest hero's. I have the utmost respect for Mr. Tom Kyte for all his efforts for bringing the concepts manual into the development world. Just to name some off the names that influenced me. But you will have to work with UNSTRUCTURED data (as Mr Date would call it). 80% of the data out there exists off it. Stuff like XMLTABLE and XML VIEWs bridge the gap between that unstructured world and the relational world. It is very doable to drag and drop an XML file into the XMLDB database into a XMLtype table and or for instance via FTP. From that point on it is in the database. From there you could move into relational tables via XMLTABLE methods or XML Views.
    You could see the described method as a filtering option so XML can be transformed into relational data. If you don't want any XML in your current database, then create an small Oracle database with XML DB installed (if doable 11.1.0.7 regarding the best performance --> all the new fast optimizer stuff etc). Use that database as a staging area that does all the XML shredding for you into relational components and ship the end result via database links and or materialized views or other probably known methodes into your relational database that isn't allowed to have XMLType.
    This way you would keep your realtional Oracle database clean and have the Oracle XML DB staging database do all the filtering and shredding into relational components.
    Throwing the XML DB option out off the window beforehand would be like replacing your Mercedes with a bicycle. With both you will be able to travel the distance from Paris to Rome, but it will take you a hell of lot longer.
    :-)

  • Insert Insert XML file into multiple records in Oracle Database

    I would like to find out if it is possible to insert a single XML file into multiple records or tuples in a Oracle database table. I have a single XML file which is at multiple levels. The meta data for the levels are common and each level can have meta data of their own in addition. I do not have any meta data field which will uniquely determine whether the data belongs to Root level, Intermediate level or at the document level. Is there any way I can determine which level the meta data belongs to and thereby make a corresponding entry into the database table tuple? For example I could have an attribute called level which is going to be present only in the database table and not in the XML file. If level=1 then it corresponds to "Root" meta data, if level=2 then it corresponds to "Intermediate" level and if level=3 then it corresponds to meta data at document level. I need a way to calculate the value for level from the XML file and thereby insert the meta data element into a tuple in a single table in Oracle.

    Hi,
    extract your xml and then you can use insert all clause.
    here's very small example on 10.2.0.1.0
    SQL> create table table1(id number,val varchar2(10));
    Table created.
    SQL> create table table2(id number,val varchar2(10));
    Table created.
    SQL> insert all
      2  into table1 values(id,val)
      3  into table2 values(id2,val2)
      4  select extractValue(x.col,'/a/id1') id
      5        ,extractValue(x.col,'/a/value') val
      6        ,extractValue(x.col,'/a/value2') val2
      7        ,extractValue(x.col,'/a/id2') id2
      8  from (select xmltype('<a><id1>1</id1><value>a</value><id2>2</id2><value2>b</value2></a>') col from dual) x;
    2 rows created.
    SQL> select * from table1;
            ID VAL                                                                 
             1 a                                                                   
    SQL> select * from table2;
            ID VAL                                                                 
             2 b                                                                    Ants

  • Insert XML content  from BLS to oracle table

    Hi,
    Is there any way to send XML content from BLS to Oracle table. I tried with FixedQueryWithOuput. It works, but it has limitation, it cannot take more than 4000 character , even though the param is configured as clob in oracle database side?

    Sajjad
    This is not issue from xMII-side itself, instead this is an Oracle issue itself. This has some limitation in manipulating data in Database.
    Managing CLOBs and BLOBs in JDBC is not very simple when compared to managing small amount of data. The way the CLOB and the BLOB objects are created and managed is different than a VARCHAR(String) column. In fact, Oracle extension classes are provided to support these types objects in JDBC like oracle.sql.CLOB, oracle.sql.BLOB etc.
    The new enhancements in Oracle JDBC 10g promises to simplify the insertion and retrieval techniques for the CLOBs using the standard APIs. This document enumerates how easily the CLOB data can be handled in JDBC, by harnessing the new features of the Oracle JDBC 10g driver
    Anyway, to more get info on Oracle problems u may read  <a href="http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/clob10g/handlingclobsinoraclejdbc10g.html">this</a>
    Regards
    Som

Maybe you are looking for

  • MySQL Database Connection (two databases at the same time)

    I have never had to open more than one MySQL database from within the same website before, but I do now.  The website I have is designed where all the content comes from within the main database.  I am building an Inventory system that I want within

  • Help for a Designer

    I have a quad core imac with os 10.7.2. I am using Flash Builder 4.5 with the latest AIR sdk. I am trying to create an app that can convert and manipulate a collada file. Papervision, Flartoolkit and the ColladaAIR Viewer is installed in FB. I am usi

  • Javax.mail.MessagingException: 502 unimplemented (#5.5.1)

    hi, I am facing a problem in sending mail. My program is running on a linux operating system and Tomcat 5.5 . So my problem is that when I try to execute that program I get the FOLLOWING EXCEPTION. I am not getting why that exception is occuring. jav

  • Anyone? (upgraded Macbook Pro 2.4ghz) ?

    Has anyone here done an upgrade to their macbook pro 2.4ghz from Tiger to Leopard without any issues? .. .like slowness in leopard or anything...

  • Email not connecting

    I have been away travelling for a few days and three days ago, my iPad (iOS 8.2) failed to connect to my two email providers. Now I am home, and although the device indicates 'connected' (and I can get my emails on my home PC using the same ISP), I c