Querying XML data in  Object Relational tables

Hi,
Can someone help me?
I have registered the purchaseorder.xsd in my database schema.
[ http://www.oracle.com/technology/oramag/oracle/03-jul/o43xml.html ]
declare
l_bfile bfile;
begin
l_bfile := bfilename(
'XMLSAMP', 'purchaseOrder.xsd');
dbms_lob.open(l_bfile);
dbms_xmlschema.registerschema('http://localhost:8080/purchaseOrder.xsd', l_bfile);
dbms_lob.close(l_bfile);
end;
This has created a table "PURCHASEORDER"
SYS_NC_ROWINFO$ SYS.XMLTYPE
It has also created object types.
select object_name from user_objects where object_type = 'TYPE' and object_name like 'XDBPO%'
XDBPO_ACTIONS_TYPE
XDBPO_ACTION_COLLECTION
XDBPO_ACTION_TYPE
XDBPO_LINEITEMS_TYPE
XDBPO_LINEITEM_TYPE
XDBPO_PART_TYPE
XDBPO_REJECTION_TYPE
XDBPO_SHIPINSTRUCTIONS_TYPE
XDBPO_TYPE
I have also inserted an xml into that table.
INSERT INTO "PURCHASEORDER"
VALUES
xmltype
getFileContent('ADAMS-20011127121040988PST.xml','XMLSAMP')
Now how do I retrieve the data from this table and the other object types?
Is extractvalue the only method? I have gone thru examples in the net but everything uses the element names in xml document and not the object type names.
For example to retreive the lineitem details, this query can be used
SELECT extractValue(value(d),'/Description')
FROM "PURCHASEORDER" p,
table (xmlsequence(extract(p.SYS_NC_ROWINFO$,'/PurchaseOrder/LineItems/LineItem/Description'))) d
But I want to retreive it from "XDBPO_LINEITEM_TYPE".
Is this possible?
Can someone help me please?
Thanks in advance.
Jay

#1. If you had taken the time to read some of the other posts in the forum all of the answers you needed were all there..
#2. As PM's we are not expected to spend a lot of time dealing with the forums. In general we are expected only to step in and answer the questions that are not easily answered by carefully reading existing posts or deal with cases were the wrong answer is supplied.
#3. I'm technically on vacation, and posted to that effect last week, so pushing for an answer is not at all appreciated...
#4. The problem is extremely simple, at least as stated in your simple example.
Given the schema.. Note It's been annotated
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
     <xs:element name="Bill">
          <xs:complexType>
               <xs:sequence>
                    <xs:element ref="InvCtlN"/>
                    <xs:element ref="MedBU"/>
                    <xs:element ref="Lineitem" maxOccurs="unbounded"/>
               </xs:sequence>
          </xs:complexType>
     </xs:element>
     <xs:element name="InvCtlN">
          <xs:simpleType>
               <xs:restriction base="xs:byte">
               </xs:restriction>
          </xs:simpleType>
     </xs:element>
     <xs:element name="LineCode">
          <xs:simpleType>
               <xs:restriction base="xs:int">
               </xs:restriction>
          </xs:simpleType>
     </xs:element>
     <xs:element name="Lineitem">
          <xs:complexType>
               <xs:sequence>
                    <xs:element ref="Type"/>
                    <xs:element ref="LineCode"/>
               </xs:sequence>
          </xs:complexType>
     </xs:element>
     <xs:element name="MedBU">
          <xs:simpleType>
               <xs:restriction base="xs:string">
               </xs:restriction>
          </xs:simpleType>
     </xs:element>
     <xs:element name="SampleFile" xdb:defaultTable="SAMPLE_FILE_TABLE">
          <xs:complexType>
               <xs:sequence>
                    <xs:element ref="Bill" maxOccurs="unbounded"/>
               </xs:sequence>
          </xs:complexType>
     </xs:element>
     <xs:element name="Type">
          <xs:simpleType>
               <xs:restriction base="xs:string">
               </xs:restriction>
          </xs:simpleType>
     </xs:element>
</xs:schema>and the following instance
<SampleFile xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="testcase.xsd">
     <Bill>
          <InvCtlN>1</InvCtlN>
          <MedBU>ABC</MedBU>
          <Lineitem>
               <Type>P1</Type>
               <LineCode>99214</LineCode>
          </Lineitem>
     </Bill>
     <Bill>
          <InvCtlN>2</InvCtlN>
          <MedBU>DEF</MedBU>
          <Lineitem>
               <Type>P2</Type>
               <LineCode>99215</LineCode>
          </Lineitem>
          <Lineitem>
               <Type>P3</Type>
               <LineCode>99216</LineCode>
          </Lineitem>
     </Bill>
     <Bill>
          <InvCtlN>3</InvCtlN>
          <MedBU>HJK</MedBU>
          <Lineitem>
               <Type>P4</Type>
               <LineCode>99217</LineCode>
          </Lineitem>
     </Bill>
</SampleFile>The following appears to be what you are looking for
SQL*Plus: Release 10.2.0.2.0 - Production on Mon Feb 20 22:42:53 2006
Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
SQL> spool registerSchema_&4..log
SQL> set trimspool on
SQL> connect &1/&2
Connected.
SQL> --
SQL> declare
  2    result boolean;
  3  begin
  4    result := dbms_xdb.createResource('/home/&1/xsd/&4',
  5                                      bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
  6  end;
  7  /
old   4:   result := dbms_xdb.createResource('/home/&1/xsd/&4',
new   4:   result := dbms_xdb.createResource('/home/OTNTEST/xsd/testcase.xsd',
old   5:                                    bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
new   5:                                    bfilename(USER,'testcase.xsd'),nls_charset_id('AL32UTF8'));
PL/SQL procedure successfully completed.
SQL> commit
  2  /
Commit complete.
SQL> alter session set events='31098 trace name context forever'
  2  /
Session altered.
SQL> begin
  2    dbms_xmlschema.registerSchema
  3    (
  4      schemaURL => '&3',
  5      schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
  6      local     => TRUE,
  7      genTypes  => TRUE,
  8      genBean   => FALSE,
  9      genTables => &5
10    );
11  end;
12  /
old   4:     schemaURL => '&3',
new   4:     schemaURL => 'testcase.xsd',
old   5:     schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
new   5:     schemaDoc => xdbURIType('/home/OTNTEST/xsd/testcase.xsd').getClob(),
old   9:     genTables => &5
new   9:     genTables => TRUE
PL/SQL procedure successfully completed.
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL*Plus: Release 10.2.0.2.0 - Production on Mon Feb 20 22:42:55 2006
Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
SQL> spool insertFile_&3..log
SQL> set trimspool on
SQL> connect &1/&2
Connected.
SQL> --
SQL> set timing on
SQL> set long 10000
SQL> --
SQL> insert into &4 values (xmltype(bfilename(USER,'&3'),nls_charset_id('AL32UTF8')))
  2  /
old   1: insert into &4 values (xmltype(bfilename(USER,'&3'),nls_charset_id('AL32UTF8')))
new   1: insert into SAMPLE_FILE_TABLE values (xmltype(bfilename(USER,'testcase.xml'),nls_charset_id('AL32UTF8')
1 row created.
Elapsed: 00:00:00.06
SQL> commit
  2  /
Commit complete.
Elapsed: 00:00:00.00
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL*Plus: Release 10.2.0.2.0 - Production on Mon Feb 20 22:42:55 2006
Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
SQL> spool testcase.log
SQL> --
SQL> connect &1/&2
Connected.
SQL> --
SQL> --
SQL> -- Testcase code here
SQL> --
SQL> set trimspool on
SQL> set autotrace on explain
SQL> set timing on
SQL> set pages 10 lines 160 long 100000
SQL> --
SQL> column INVCTLN format  9999
SQL> column MEDBU   format  A10
SQL> column TYPE    format  A10
SQL> column LINECODE format 999999999
SQL> create or replace view MASTER_TABLE_VIEW
  2  (
  3     INVCTLN,
  4     MEDBU
  5  )
  6  as
  7  select extractValue(value(bill),'/Bill/InvCtlN'),
  8         extractValue(value(bill),'/Bill/MedBU')
  9    from SAMPLE_FILE_TABLE t,
10         table(xmlsequence(extract(value(t),'/SampleFile/Bill'))) Bill
11  /
View created.
Elapsed: 00:00:00.04
SQL> create or replace view DETAIL_TABLE_VIEW
  2  (
  3     INVCTLN,
  4     TYPE,
  5     LINECODE
  6  )
  7  as
  8  select extractValue(value(bill),'/Bill/InvCtlN'),
  9         extractValue(value(LineItem),'/Lineitem/Type'),
10         extractValue(value(LineItem),'/Lineitem/LineCode')
11    from SAMPLE_FILE_TABLE t,
12         table(xmlsequence(extract(value(t),'/SampleFile/Bill'))) Bill,
13         table(xmlsequence(extract(value(bill),'/Bill/Lineitem'))) LineItem
14  /
View created.
Elapsed: 00:00:00.05
SQL> set autotrace on explain
SQL> --
SQL> select * from MASTER_TABLE_VIEW
  2  /
INVCTLN MEDBU
      1 ABC
      2 DEF
      3 HJK
Elapsed: 00:00:00.05
Execution Plan
Plan hash value: 2362844891
| Id  | Operation          | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT   |                    |     3 |  6165 |   805   (1)| 00:00:10 |
|   1 |  NESTED LOOPS      |                    |     3 |  6165 |   805   (1)| 00:00:10 |
|*  2 |   TABLE ACCESS FULL| SAMPLE_FILE_TABLE  |     1 |    30 |     3   (0)| 00:00:01 |
|*  3 |   INDEX RANGE SCAN | SYS_IOT_TOP_159053 |     3 |  6075 |     1   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   2 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege
              xmlns="http://xmlns.oracle.com/xdb/acl.xsd"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
              http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><rea
              d-properties/><read-contents/></privilege>'))=1)
   3 - access("NESTED_TABLE_ID"="SAMPLE_FILE_TABLE"."SYS_NC0000800009$")
Note
   - dynamic sampling used for this statement
SQL> select * from DETAIL_TABLE_VIEW
  2  /
INVCTLN TYPE         LINECODE
      1 P1              99214
      3 P4              99217
      2 P2              99215
      2 P3              99216
Elapsed: 00:00:00.07
Execution Plan
Plan hash value: 971642473
| Id  | Operation               | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT        |                    |     4 |  8352 |   813   (0)| 00:00:10 |
|   1 |  NESTED LOOPS           |                    |     4 |  8352 |   813   (0)| 00:00:10 |
|   2 |   MERGE JOIN CARTESIAN  |                    |     4 |  8220 |   805   (0)| 00:00:10 |
|*  3 |    TABLE ACCESS FULL    | SAMPLE_FILE_TABLE  |     1 |    30 |     3   (0)| 00:00:01 |
|   4 |    BUFFER SORT          |                    |     4 |  8100 |   802   (0)| 00:00:10 |
|   5 |     INDEX FAST FULL SCAN| SYS_IOT_TOP_159055 |     4 |  8100 |   802   (0)| 00:00:10 |
|*  6 |   INDEX UNIQUE SCAN     | SYS_IOT_TOP_159053 |     1 |    33 |     2   (0)| 00:00:01 |
|*  7 |    INDEX RANGE SCAN     | SYS_C0022871       |     1 |       |     0   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   3 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege
              xmlns="http://xmlns.oracle.com/xdb/acl.xsd"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
              http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-pro
              perties/><read-contents/></privilege>'))=1)
   6 - access("NESTED_TABLE_ID"="SYS_NTh/v83GzKQ1evte63P5QRog=="."SYS_NC0000700008$")
       filter("NESTED_TABLE_ID"="SAMPLE_FILE_TABLE"."SYS_NC0000800009$")
   7 - access("NESTED_TABLE_ID"="SYS_NTh/v83GzKQ1evte63P5QRog=="."SYS_NC0000700008$")
Note
   - dynamic sampling used for this statement
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
C:\xdb\otn\362337>

Similar Messages

  • Retrieve xml data from a relational table(oracle) with datatype as xmltyp

    Hello Avijit, any resolution for this issue?

    hi .... I am trying to retrieve xml data from a relational table with datatype as xmltyp. The SQ is retrieving rows but the xml parser give transformation error . The transformation retrieve xml data from a relational table(oracle) with datatype as xmltyp returned a row error status on receiving an input row on group retrieve xml data from a relational table(oracle) with datatype as xmltyp.  ERROR : An XML document was truncated and thus not processed. Input row from SQ_XMLTYPE_TEST: Rowdata: ( RowType=0(insert) Src Rowid=5 Targ Rowid=5 DOCUMENT (DataInput:Char.64000:): "<?xml version='1.0' encoding='UTF-8'?><main><DATA_RECORD> <OFFER_ID>434345</OFFER_ID> <ADDR>sec -2 salt lake</ADDR> <CITY>kolkata</CITY> (DISPLAY TRUNCATED)(TRUNCATED)" )  thanks in advance Avijit

  • Retrieving data from a relational table and CLOB as a whole XML file

    I created the table lob_example and I have managed to insert XML document into it using XML SQL Utility. In this document I put contents of <DESCRIPTION> tag into CDATA section.
    LOB_EXAMPLE
    Name Null? Type
    ID NOT NULL NUMBER
    DESCRIPTION CLOB
    NAME VARCHAR2(40)
    But I could not retrieve this data properly. I can think of only one solution - to parse and build the whole XMLDocument. I found the suggestion of another solution to use Oracle8i views to do that in http://technet.oracle.com/tech/xml/infoocs/otnwp/about_oracle_xml_products.htm, but this text is not clear enough for me.
    I would like to quote the fragment from document mentioned above, which is ambiguous for me:
    "Combining XML Documents and Data Using Views
    Finally, if you have a combination of structured and unstructured XML data, but still want to view and operate on it as a whole, you can use Oracle8i views. Views enable you to construct an object on the "fly" by combining XML data stored in a variety of ways. So, you can store structured data (such as employee data, customer data, and so on) in one location within object -relational tables, and store related unstructured data (such as descriptions and comments) within a CLOB. When you need to retrieve the data as a whole, you simply construct the structure from the various pieces of data with the use of type constructors in the view's select statement. The XML SQL Utility then enables retrieving the constructed data from the view as a single XML document."
    The main question is - how to use type constructors in the view's select statement?

    Hello
    Sorry for asking the same question again, but any responses would be greatly appreciated.
    How to use type constructors in the view's select statement?
    I could not find any answers for this question on Technet. Maybe the other approaches are more efficient to combine the part of data from CLOB with data from other column types?
    Thank you

  • Select data from an XML Column in a Relational Table

    Hi guys,
    I read a lot of documentation from Oracle how to select xml nodes from an XML Table. The following statement works perfectly for an XML table.
    select extract(OBJECT_VALUE, '/loop/loop_data/description') "DESCRIPTION"
    from loop_table
    where xmlexists('/loop/loop_data[type_code="212"]' PASSING OBJECT_VALUE);
    BUT: how to select xml nodes (data) from a relational table with an XML column???
    I'm interested in the xml data.
    Thanks!
    Miro

    I've tried the same but i don't get any results
    WITH BOL_JMS_MESSAGES_TMP AS
    (SELECT 1 pk,
    XMLTYPE('<MESSAGE_ENVELOPE>
    <ORDER>
    <DIRECT_TURNOVER>N</DIRECT_TURNOVER>
    <DATE_PLACED>2010-05-06T17:14:35.189+02:00</DATE_PLACED>
    <PAYMENT_TYPE>02</PAYMENT_TYPE>
    <ACCOUNT_NUMBER>108317412</ACCOUNT_NUMBER>
    <GIFT_FLAG>N</GIFT_FLAG>
    <ID>7788783900</ID>
    <NETPRICE>117.21</NETPRICE>
    <VAT>7.69</VAT>
    <TOTALPRICE>126.85</TOTALPRICE>
    <SHIPHAND_COSTS>1.64</SHIPHAND_COSTS>
    <SHIPHAND_VAT>0.31</SHIPHAND_VAT>
    <SHIPEQUALBILL_FLAG>Y</SHIPEQUALBILL_FLAG>
    <SHIPPING_METHOD>01</SHIPPING_METHOD>
    </ORDER>
    </MESSAGE_ENVELOPE>') rnd_col
    from dual
    select extract(rnd_col, '/message_envelope/order/direct_turnover/date_placed/payment_type/account_number/gift_flag/id/netprice/vat/totalprice/shiphand_costs/shiphand_vat/shipequalbill_flag/SHIPPING_METHOD') "Payment type"
    FROM BOL_JMS_MESSAGES_TMP
    WHERE existsNode(rnd_col,'/message_envelope') = 1;
    No rows.
    Eventually i want to update the payment type from 02 to 00.

  • Query xml data from a CLOB datatye

    All,
    I read in an oracle white paper that is is possible to query XML data from CLOB datatype using oracle text index using operators HASPATH() and INPATH(). I am not able to find any example on how to do this. Can someone please post a simple example here.
    Thank You very much!

    SCOTT@10gXE> CREATE TABLE your_table (id NUMBER, xml_data CLOB)
      2  /
    Table created.
    SCOTT@10gXE> INSERT INTO your_table (id, xml_data)
      2  SELECT t.deptno,
      3           DBMS_XMLGEN.GETXML
      4             ('SELECT d.dname,
      5                   CURSOR (SELECT e.ename, e.job
      6                        FROM   emp e
      7                        WHERE  e.deptno = d.deptno) emp_data
      8            FROM   dept d
      9            WHERE  d.deptno = ' || t.deptno)
    10  FROM   dept t
    11  /
    5 rows created.
    SCOTT@10gXE> COMMIT
      2  /
    Commit complete.
    SCOTT@10gXE> begin
      2    ctx_ddl.create_section_group('xmlpathgroup', 'PATH_SECTION_GROUP');
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SCOTT@10gXE> CREATE INDEX myindex
      2  ON your_table(xml_data)
      3  INDEXTYPE IS ctxsys.context
      4  PARAMETERS ('datastore ctxsys.default_datastore
      5              filter ctxsys.null_filter
      6              section group xmlpathgroup'
      7            )
      8  /
    Index created.
    SCOTT@10gXE> SELECT * FROM your_table
      2  WHERE  CONTAINS (xml_data, 'PERSONNEL INPATH (//DNAME)') > 0
      3  /
            ID XML_DATA
            50 <?xml version="1.0"?>
               <ROWSET>
                <ROW>
                 <DNAME>PERSONNEL</DNAME>
                 <EMP_DATA>
                 </EMP_DATA>
                </ROW>
               </ROWSET>
    SCOTT@10gXE> SELECT * FROM your_table
      2  WHERE  CONTAINS (xml_data, 'HASPATH (//DNAME="PERSONNEL")') > 0
      3  /
            ID XML_DATA
            50 <?xml version="1.0"?>
               <ROWSET>
                <ROW>
                 <DNAME>PERSONNEL</DNAME>
                 <EMP_DATA>
                 </EMP_DATA>
                </ROW>
               </ROWSET>
    SCOTT@10gXE> SELECT * FROM your_table
      2  WHERE  CONTAINS (xml_data, 'CLARK INPATH (//ENAME)') > 0
      3  /
            ID XML_DATA
            10 <?xml version="1.0"?>
               <ROWSET>
                <ROW>
                 <DNAME>ACCOUNTING</DNAME>
                 <EMP_DATA>
                  <EMP_DATA_ROW>
                   <ENAME>CLARK</ENAME>
                   <JOB>MANAGER</JOB>
                  </EMP_DATA_ROW>
                  <EMP_DATA_ROW>
                   <ENAME>KING</ENAME>
                   <JOB>PRESIDENT</JOB>
                  </EMP_DATA_ROW>
                  <EMP_DATA_ROW>
                   <ENAME>MILLER</ENAME>
                   <JOB>CLERK</JOB>
                  </EMP_DATA_ROW>
                 </EMP_DATA>
                </ROW>
               </ROWSET>
    SCOTT@10gXE> SELECT * FROM your_table
      2  WHERE  CONTAINS (xml_data, 'HASPATH (//ENAME="CLARK")') > 0
      3  /
            ID XML_DATA
            10 <?xml version="1.0"?>
               <ROWSET>
                <ROW>
                 <DNAME>ACCOUNTING</DNAME>
                 <EMP_DATA>
                  <EMP_DATA_ROW>
                   <ENAME>CLARK</ENAME>
                   <JOB>MANAGER</JOB>
                  </EMP_DATA_ROW>
                  <EMP_DATA_ROW>
                   <ENAME>KING</ENAME>
                   <JOB>PRESIDENT</JOB>
                  </EMP_DATA_ROW>
                  <EMP_DATA_ROW>
                   <ENAME>MILLER</ENAME>
                   <JOB>CLERK</JOB>
                  </EMP_DATA_ROW>
                 </EMP_DATA>
                </ROW>
               </ROWSET>
    SCOTT@10gXE>

  • Printing out results in case of object-relational table (Oracle)

    I have made a table with this structure:
    CREATE OR REPLACE TYPE Boat AS OBJECT(
    Name varchar2(30),
    Ident number,
    CREATE OR REPLACE TYPE Type_boats AS TABLE OF Boat;
    CREATE TABLE HOUSE(
    Name varchar2(40),
    MB Type_boats)
    NESTED TABLE MB store as P_Boat;
    INSERT INTO House VALUES ('Name',Type_boats(Boat('Boat1', 1)));
    I am using java to print out all the results by calling a procedure.
    CREATE OR REPLACE package House_boats
    PROCEDURE add(everything works here)
    PROCEDURE results_view;
    END House_boats;
    CREATE OR REPLACE Package.body House_boats AS
    PROCEDURE add(everything works here) AS LANGUAGE JAVA
    Name House_boats.add(...)
    PROCEDURE results_view AS LANGUAGE JAVA
    Name House_boats.resuts_view();
    END House_boats;
    However, I am not able to get Results.view working in case of object-relation table. This is how I do it in the situation of relational table.
    CALL House_boats.results_view();
    House_boats.java file which is loaded using LOADJAVA:
    import java.sql.*;
    import java io.*;
    public class House_boats {
    public static void results_view ()
       throws SQLException
       { String sql =
       "SELECT * from House";
       try { Connection conn = DriverManager.getConnection
    ("jdbc:default:connection:");
       PreparedStatement pstmt = conn.prepareStatement(sql);
       ResultSet rset = pstmt.executeQuery();
      printResults(rset);
      rset.close();
      pstmt.close();
       catch (SQLException e) {System.err.println(e.getMessage());
    static void printResults (ResultSet rset)
       throws SQLException { String buffer = "";
       try { ResultSetMetaData meta = rset.getMetaData();
       int cols = meta.getColumnCount(), rows = 0;
       for (int i = 1; i <= cols; i++)
       int size = meta.getPrecision(i);
       String label = meta.getColumnLabel(i);
       if (label.length() > size) size = label.length();
       while (label.length() < size) label += " ";
      buffer = buffer + label + " "; }
      buffer = buffer + "\n";
       while (rset.next()) {
      rows++;
       for (int i = 1; i <= cols; i++) {
       int size = meta.getPrecision(i);
       String label = meta.getColumnLabel(i);
       String value = rset.getString(i);
       if (label.length() > size) size = label.length();
       while (value.length() < size) value += " ";
      buffer = buffer + value + " ";  }
      buffer = buffer + "\n";   }
       if (rows == 0) buffer = "No data found!\n";
       System.out.println(buffer); }
       catch (SQLException e) {System.err.println(e.getMessage());}  }
    How do I print out the results correctly in my case of situation?
    Thank you in advance

    I have made a table with this structure:
    I am using java to print out all the results by calling a procedure.
    However, I am not able to get Results.view working in case of object-relation table. This is how I do it in the situation of relational table.
    How do I print out the results correctly in my case of situation?
    There are several things wrong with your code and methodology
    1. The code you posted won't even compile because there are several syntax issues.
    2. You are trying to use/test Java in the database BEFORE you get the code working outside the DB
    3. Your code is not using collections in JDBC properly
    I suggest that you use a different, proven approach to developing Java code for use in the DB
    1. Use SIMPLE examples and then build on them. In this case that means don't add collections to the example until ALL other aspects of the app work properly.
    2. Create and test the Java code OUTSIDE of the database. It is MUCH easier to work outside the database and there are many more tools to help you (e.g. NetBeans, debuggers, DBMS_OUTPUT windows, etc). Trying to debug Java code after you have already loaded it into the DB is too difficult. I'm not aware of anyone, even at the expert level, that develops that way.
    3. When using complex functionality like collections first read the Oracle documentation (JDBC Developer Guide and Java Developer's Guide). Those docs have examples that are known to work.
    http://docs.oracle.com/cd/B28359_01/java.111/b31225/chfive.htm
    http://docs.oracle.com/cd/E11882_01/java.112/e16548/oraarr.htm#sthref583
    The main issue with your example is #3 above; you are not using collections properly:
    String value = rset.getString(i);
    A collection is NOT a string so why would you expect that to work for a nested table?
    A collection needs to be treated like a collection. You can even treat the collection as a separate result set. Create your code outside the database and use the debugger in NetBeans (or other) on this replacement code for your 'printResults' method:
    static void printResults (ResultSet rset) throws SQLException {
        try {
           ResultSetMetaData meta = rset.getMetaData();
           while (rset.next()) {
               ResultSet rs = rset.getArray(2).getResultSet();
               rs.next();
               String ndx = rs.getString(1);
               Struct struct = (Struct) rs.getObject(2);
               System.out.println(struct.getSQLTypeName());
               Object [] oa = struct.getAttributes();
               for (int j = 0; j < oa.length; j++) {
                  System.out.println(oa[j]);
        } catch  (SQLException e) {
           System.err.println(e.getMessage());
    That code ONLY deals with column 2 which is the nested table. It gets that collection as a new resultset ('rs'). Then it gets the contents of that nested table as an array of objects and prints out the attributes of those objects so you can see them.
    Step through the above code in a debugger so you can SEE what is happening. NetBeans also lets you enter expressions such as 'rs' in an evaluation window so you can dynamically try the different methods to see what they do for you.
    Until you get you code working outside the database don't even bother trying to load it into the DB and create a Java stored procedure.
    Since your current issue has nothing to do with this forum I suggest that you mark this thread ANSWERED and repost it in the JDBC forum if you need further help with this issue.
    https://forums.oracle.com/community/developer/english/java/database_connectivity
    When you repost you can include a link to this current thread if you want. Once your Java code is actually working then try the Java Stored procedure examples in the Java Developer's Guide doc linked above.
    At the point you have any issues that relate to Java stored procedures then you should post them in the SQL and PL/SQL forum
    https://forums.oracle.com/community/developer/english/oracle_database/sql_and_pl_sql

  • Problem inserting and querying XML data with a recursive XML schema

    Hello,
    I'm facing a problem with querying XML data that is valid against a recursive XML Schema. I have got a table category that stores data as binary XML using Oracle 11g Rel 2 on Windows XP. The XML Schema is the following:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="bold_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="keyword_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
                   <xs:element name="plain_text" type="xs:string"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="emph_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="text_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="parlist_type">
              <xs:sequence>
                   <xs:element name="listitem" minOccurs="0" maxOccurs="unbounded" type="listitem_type"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="listitem_type">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="parlist" type="parlist_type"/>
                   <xs:element name="text" type="text_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:element name="category">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="name"/>
                        <xs:element name="description">
                                  <xs:complexType>
                                            <xs:choice>
                                                           <xs:element name="text" type="text_type"/>
                                                           <xs:element name="parlist" type="parlist_type"/>
                                            </xs:choice>
                                  </xs:complexType>
                        </xs:element>
                                                                </xs:sequence>
                                                                <xs:attribute name="id"/>
                                            </xs:complexType>
                        </xs:element>
    </xs:schema>I registered this schema and created the category table. Then I inserted a new row using the code below:
    insert into category_a values
    (XMlElement("category",
          xmlattributes('categoryAAA' as "id"),
          xmlforest ('ma categ' as "name"),
          (xmlelement("description", (xmlelement("text", 'find doors blest now whiles favours carriage tailor spacious senses defect threat ope willow please exeunt truest assembly <keyword> staring travels <bold> balthasar parts attach </bold> enshelter two <emph> inconsiderate ways preventions </emph> preventions clasps better affections comes perish </keyword> lucretia permit street full meddle yond general nature whipp <emph> lowness </emph> grievous pedro')))    
    The row is successfully inserted as witnessed by the results of row counting. However, I cannot extract data from the table. First, I tried using SqlPlus* which hangs up and quits after a while. I then tried to use SQL Developer, but haven't got any result. Here follow some examples of queries and their results in SQL Developer:
    Query 1
    select * from category
    Result : the whole row is returned
    Query 2
    select xmlquery('$p/category/description' passing object_value as "p" returning content) from category
    Result: "SYS.XMLTYPE"
    now I tried to fully respect the nested structure of description element in order to extract the text portion of <bold> using this query
    Query 3
    select  xmlquery('$p/category/description/text/keyword/bold/text()' passing object_value as "p" returning content) from  category_a
    Result: null
    and also tried to extract the text portion of element <text> using this query
    Query 4
    select  xmlquery('$p/category/description/text/text()' passing object_value as "p" returning content) from  category_a
    Result: "SYS.XMLTYPE".
    On the other hand, I noticed, from the result of query 1, that the opening tags of elements keyword and bold are encoded as the less than operator "&lt;". This explains why query 3 returns NULL. However, query 4 should display the text content of <text>, which is not the case.
    My questions are about
    1. How to properly insert the XML data while preserving the tags (especially the opening tag).
    2. How to display the data (the text portion of the main Element or of the nested elements).
    The problem about question 1 is that it is quite unfeasible to write a unique insert statement because the structure of <description> is recursive. In other words, if the structure of <description> was not recursive, it would be possible to embed the elements using the xmlelement function during the insertion.
    In fact, I need to insert the content of <description> from a source table (called category_a) into a target table (+category_b+) automatically .
    I filled category_a using the Saxloader utility from an flat XML file that I have generated from a benchmark. The content of <description> is different from one row to another but it is always valid with regards to the XML Schema. The data is properly inserted as witnessed by the "select * from category_a" instruction (500 row inserted). Besides, the opening tags of the nested elements under <description> are preserved (no "&lt;"). Then I wrote a PL/SQL procedure in which a cursor extracts the category id and category name into varchar2 variables and description into an XMLtype variable from category_a. When I try to insert the values into a category_b, I get the follwing error:
    LSX-00213: only 0 occurrences of particle "text", minimum is 1which tells that the <text> element is absent (actually it is present in the source table).
    So, my third question is why are not the tags recognized during the insertion?
    Can anyone help please?

    Hello,
    indded, I was using an old version of Sqlplus* (8.0.60.0.0) because I had a previous installation (oracle 10g XE). Instead, I used the Sqlplus* shipped with the 11g2database (version 11.2.0.1.0). All the queries that I wrote work fine and display the data correctly.
    I also used the XMLSERIALIZE function and can now display the description content in SQL Developer.
    Thank you very much.
    To answer your question Marco, I registered the XML Schema using the following code
    declare
      doc varchar2(4000) := '<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="bold_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="keyword_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
                   <xs:element name="plain_text" type="xs:string"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="emph_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="text_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="parlist_type">
              <xs:sequence>
                   <xs:element name="listitem" minOccurs="0" maxOccurs="unbounded" type="listitem_type"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="listitem_type">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="parlist" type="parlist_type"/>
                   <xs:element name="text" type="text_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:element name="category">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="name"/>
                        <xs:element name="description">
                                  <xs:complexType>
                                            <xs:choice>
                                                           <xs:element name="text" type="text_type"/>
                                                           <xs:element name="parlist" type="parlist_type"/>
                                            </xs:choice>
                                  </xs:complexType>
                        </xs:element>
                                                                </xs:sequence>
                                                                <xs:attribute name="id"/>
                                            </xs:complexType>
                        </xs:element>
    </xs:schema>';
    begin
      dbms_xmlschema.registerSchema('/xmldb/category_auction.xsd', doc,     LOCAL      => FALSE, 
            GENTYPES   => FALSE,  GENBEAN    => FALSE,   GENTABLES  => FALSE,
             FORCE      => FALSE,
             OPTIONS    => DBMS_XMLSCHEMA.REGISTER_BINARYXML,
             OWNER      => USER);
    end;then, I created the Category table as follows:
    CREATE TABLE category_a of XMLType XMLTYPE store AS BINARY XML
        XMLSCHEMA "xmldb/category_auction.xsd" ELEMENT "category";Now, there still remains a problem of how to insert the "description" content which I serialized as a CLOB data into another table as XML. To this purpose, I wrote a view over the Category_a table as follows:
    CREATE OR REPLACE FORCE VIEW "AUCTION_XWH"."CATEGORY_V" ("CATEGORY_ID", "CNAME", "DESCRIPTION") AS
      select category_v."CATEGORY_ID",category_v."CNAME",
      XMLSerialize(content ( xmlquery('$p/category/description/*' passing object_value as "p" returning content)) as clob) as "DESCRIPTION"
      from  auction.category_a p, 
    xmltable ('$a/category' passing p.Object_Value as "a"
    columns  category_id varchar2(15) path '@id',
              cname varchar2(20) path 'name') category_v;Then, I wrote a procedure to insert data into the Category_xwh table (the source and target tables are slightly different: the common elements are just copied wereas new elements are created in the target table). The code of the procedure is the following:
    create or replace PROCEDURE I_CATEGORY AS
    v_cname VARCHAR2(30);
    v_description clob ;
    v_category_id VARCHAR2(15);
    cursor mycursor is select category_id, cname, description from category_v;
    BEGIN
    open mycursor;
      loop
      /*retrieving the columns*/
      fetch mycursor into v_category_id, v_cname, v_description ;
      exit when mycursor%notfound;
      insert into category_xwh values
      (XMlElement("category",
          xmlattributes(v_category_id as "category_id"),
          xmlelement("Hierarchies", xmlelement("ObjHierarchy", xmlelement ("H_Cat"),
                                                               xmlelement ("Rollsup",
                                                                                  (xmlelement("all_categories",
                                                                                   xmlattributes('allcategories' as "all_category_id")))
        xmlforest (
                  v_cname as "cat_name",
                  v_description as "description")    
    end loop;
      commit;
      close mycursor;
    END I_CATEGORY;When I execute the procedure, I get the following error:
    LSX-00201: contents of "description" should be elements onlyso, I just wonder if this is because v_description is considered as plain text and not as XML text, even if its content is XML. Do I need to use a special function to cast the CLOB as XML?
    Thanks for your help.
    Doulkifli

  • How to query XML data stored in a CLOB column

    I don't know XMLDB, so I have a dumb question about querying XML data which is saved as CLOB in a table.
    I have a table (OLAP_AW_PRC), with a CLOB column - AW_XML_TMPL_VAL
    This column contains this xml data - [click here|http://www.nasar.net/aw.xml]
    Now I want to query the data using the xml tags - like returning the name of AW. This is where I am having trouble, how to query the data from AW_XML_TMPL_VAL clob column.
    The following query generates error:
    ORA-31011: XML parsing failed.
    ORA-19202: Error occurred in XML processing
    LPX-00229: input source is empty
    SELECT
    extractValue(value(x), '/AW/LongName') as "AWNAME"
    from
    OLAP_AW_PRC,
    table(xmlsequence(extract (xmltype(AW_XML_TMPL_VAL), '/AWXML/AWXML.content/Create/ActiveObject/AW'))) x
    where
    extractValue(value(x) , '/AW/Name') = 'OMCR4'
    - Nasar

    Mark,
    Thanks. This is exactly what I was looking for.
    After doing @Name in both places (SELECT and WHERE clause) it worked.
    Now I have one more question.
    There are multiple DIMENSION tags in my xml, and I want to see the NAME attribute values for all of those DIMENSIONs. The following query returns
    ORA-19025: EXTRACTVALUE returns value of only one node.
    Cause: Given XPath points to more than one node.
    Action: Rewrite the query so that exactly one node is returned.
    SELECT
    extractValue(value(x), '/AW/@Name') as "AW",
    extractValue(value(x), '/AW/Dimension/@Name') as "DIMENSIONS"
    from
    OLAP_AW_PRC,
    table(xmlsequence(extract (xmltype(AW_XML_TMPL_VAL), '/AWXML/AWXML.content/Create/ActiveObject/AW'))) x
    where
    extractValue(value(x) , '/AW/@Name') = 'OMCR4'

  • Generate xml output file from relational table

    Hi All,
    I'd like to generate an XML file from a relational table but would like to persist the XSD in Oracle does anyone have a working example?
    Edited by: houchen on Jun 2, 2009 5:34 AM

    From the FAQ on the {forum:id=34} forum, {thread:id=416001}.
    If you are wanting to register the schemas in Oracle, you will find info on that as well in the FAQ.

  • How do you end date an objective in table per_objectives_library?

    Hi,
    I would like to find out how to end date an objective in table per_objectives_library.
    I have checked HR_OBJECTIVES_API.update_objective but there is parameters there for Valid_from and Valid_to dates. Is there any other API Package that can be used to do this?
    Thanks
    Shalantha

    Ok, found it....will use HR_OBJECTIVE_LIBRARY_API

  • Date insertion from large XML document (clob) into relation table very slow

    Hi Everybody!
    I'm working with Oracle 9.2.0.5 on Microsoft Windows Server 2003 Enterprise Edition.
    The server (a test server) is a Pentium 4 2.8 GHz, 1GB of RAM.
    I use a procedure called PARITOP_TRAITERXMLRESULTMASSE to insert the data contained in the pXMLDOC clob parameter in the table pTABLENAME. (You can see the format of the XML document below). The first step on this procedure is to verify that the XML document is not empty. If not, the procedure needs to add a node in the document, in every <ROW> tag. This added node is named “RST_ID”. It’s the foreign key of each record. I can retrieve the value of each <RST_ID> node in an other table in which the data has been previously added (by the calling procedure). When each of the <ROW> elements has been treated, the PARITOP_INSERTXML procedure is called. This procedure uses DBMS_XMLSAVE.INSERTXML to insert the data contained in the XML document in the specified table.
    (Below, you can see the code of my procedures.)
    With this information, can you tell me why this treatment is very very very slow with a large XML document and how I can improve it?
    Thank you for your help!
    Anne-Marie
    CREATE OR REPLACE PROCEDURE "PARITOP_TRAITERXMLRESULTMASSE" (
    pPRC_ID IN PARITOP_PARC.PRC_ID%TYPE,
    pRST_MONDE IN PARITOP_RESULTAT.RST_MONDE%TYPE,
    pXMLDOC IN CLOB,
    pTABLENAME IN VARCHAR2)
    AS
    Objectif :Insérer le contenu du XML passé en paramètre (pXMLDOC) à la table passée en paramètre (pTABLENAME)
    La table passée en paramètre doit être une table ayant comme clé étrangère le champs "RST_ID" .
    (Le noeud RST_ID est donc ajouté à tous les document XML. Ce rst_id est
    déterminé à partir de la table PARITOP_RESULTAT grâce à pPRC_ID et
    pRstMonde fournis en paramètre)
    result_doc CLOB;
    XMLDOMDOC XDB.DBMS_XMLDOM.DOMDOCUMENT;
    NODE_ROWSET DBMS_XMLDOM.DOMNODE;
    NODE_ROW DBMS_XMLDOM.DOMNODE;
    vUE_ID PARITOP_RESULTAT.UE_ID%TYPE;
    vRST_ID PARITOP_RESULTAT.RST_ID%TYPE;
    nodeList DBMS_XMLDOM.DOMNODELIST;
    BEGIN
    BEGIN
    vUE_ID := 0;
    vRST_ID := 0;
    XMLDOMDOC := DBMS_XMLDOM.NEWDOMDOCUMENT(pXMLDOC);
    IF NOT GESTXML_PKG.FN_PARITOP_DOCUMENT_IS_NULL(XMLDOMDOC) THEN
    NODE_ROWSET := DBMS_XMLDOM.item(DBMS_XMLDOM.GETCHILDNODES (DBMS_XMLDOM.MAKENODE(XMLDOMDOC)),0);
    for i in 0..dbms_xmldom.getLength(DBMS_XMLDOM.getchildnodes(NODE_ROWSET))-1 loop
    NODE_ROW := DBMS_XMLDOM.ITEM(DBMS_XMLDOM.GETCHILDNODES(NODE_ROWSET), i) ;
    nodeList := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(DBMS_XMLDOM.makeelement(NODE_ROW) , 'UE_ID');
    IF vUE_ID <> DBMS_XMLDOM.GETNODEVALUE(DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.ITEM(nodeList, 0))) THEN
    vUE_ID := DBMS_XMLDOM.GETNODEVALUE(DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.ITEM(nodeList, 0)));
    --on ramasse le rst_id
    SELECT RST_ID INTO vRST_ID
    FROM PARITOP_RESULTAT RST
    WHERE RST.PRC_ID = pPRC_ID
    AND RST.UE_ID = vUE_ID
    AND RST.RST_MONDE = pRST_MONDE
    AND RST_A_SUPPRIMER = 0;
    END IF;
    GESTXML_PKG.PARITOP_ADDNODETOROW(XMLDOMDOC, NODE_ROW, 'RST_ID', vRST_ID);
    end loop;
    RESULT_DOC := ' '; --à garder, pour ne pas que ca fasse d'erreur lors du WriteToClob.
    dbms_xmldom.writeToClob(DBMS_XMLDOM.MAKENODE(XMLDOMDOC), RESULT_DOC);
    --Insertion du document XML dans la table "tableName"
    GESTXML_PKG.PARITOP_INSERTXML(RESULT_DOC, pTABLENAME);
    DBMS_XMLDOM.FREEDOCUMENT( XMLDOMDOC);
    end if;
    EXCEPTION
    […exception treatement…]
    END;
    END;
    The format of a XML clob is :
    <ROWSET>
    <ROW>
    <PRC_ID>193</PRC_ID>
    <UE_ID>8781</UE_ID>
    <VEN_ID>6223</VEN_ID>
    <RST_MONDE>0</RST_MONDE>
    <CMP_SELMAN>0</CMP_SELMAN>
    <CMP_INDICESELECTION>92.307692307692307</CMP_INDICESELECTION>
    <CMP_PVRES>94900</CMP_PVRES>
    <CMP_PVAJUSTE>72678.017699115066</CMP_PVAJUSTE>
    <CMP_PVAJUSTEMIN>72678.017699115095</CMP_PVAJUSTEMIN>
    <CMP_PVAJUSTEMAX>72678.017699115037</CMP_PVAJUSTEMAX>
    <CMP_PV>148000</CMP_PV>
    <CMP_VALROLE>129400</CMP_VALROLE>
    <CMP_PVRESECART>4790</CMP_PVRESECART>
    <CMP_PVRHAB>101778.01769911509</CMP_PVRHAB>
    <CMP_UTILISE>1</CMP_UTILISE>
    <CMP_TVM>1</CMP_TVM>
    <CMP_PVA>148000</CMP_PVA>
    </ROW>
    <ROW>
    <PRC_ID>193</PRC_ID>
    <UE_ID>8781</UE_ID>
    <VEN_ID>6235</VEN_ID>
    <RST_MONDE>0</RST_MONDE>
    <CMP_SELMAN>0</CMP_SELMAN>
    <CMP_INDICESELECTION>76.92307692307692</CMP_INDICESELECTION>
    <CMP_PVRES>117800</CMP_PVRES>
    <CMP_PVAJUSTE>118080</CMP_PVAJUSTE>
    <CMP_PVAJUSTEMIN>118080</CMP_PVAJUSTEMIN>
    <CMP_PVAJUSTEMAX>118080</CMP_PVAJUSTEMAX>
    <CMP_PV>172000</CMP_PV>
    <CMP_VALROLE>134800</CMP_VALROLE>
    <CMP_PVRESECART>0</CMP_PVRESECART>
    <CMP_PVRHAB>147180</CMP_PVRHAB>
    <CMP_UTILISE>1</CMP_UTILISE>
    <CMP_TVM>1</CMP_TVM>
    <CMP_PVA>172000</CMP_PVA>
    </ROW>
    </ROWSET>
    PARITOP_COMPARABLE TABLE :
    RST_ID NUMBER(10) NOT NULL,
    VEN_ID NUMBER(10) NOT NULL,
    CMP_SELMAN NUMBER(1) NOT NULL,
    CMP_UTILISE NUMBER(1) NOT NULL,
    CMP_INDICESELECTION FLOAT(53) NOT NULL,
    CMP_PVRES FLOAT(53) NULL,
    CMP_PVAJUSTE FLOAT(53) NULL,
    CMP_PVRHAB FLOAT(53) NULL,
    CMP_TVM FLOAT(53) NULL
    ROCEDURE PARITOP_INSERTXML (xmlDoc IN clob, tableName IN VARCHAR2)
    AS
    insCtx DBMS_XMLSave.ctxType;
    rowss number;
    BEGIN
    --permet d'insérer les champs du XML dans la table passée en paramètre.
    --il suffit que les champs XML aient le même nom que les champs de la table
    BEGIN
    insCtx := DBMS_XMLSave.newContext(tableName); -- get context handle
    DBMS_XMLSAVE.SETDATEFORMAT( insCtx, 'yyyy-MM-dd HH:mm:ss');--attention, case sensitive
    DBMS_XMLSAVE.setIgnoreCase(insCtx, 1);
    rowss := DBMS_XMLSAVE.INSERTXML(insCtx , xmlDoc);
    DBMS_XMLSave.closeContext(insCtx);
    EXCEPTION
    […]
    END;
    END;
    PROCEDURE PARITOP_ADDNODETOROW (
    XMLDOMDOC DBMS_XMLDOM.DOMDOCUMENT,
    NODE_ROW dbms_xmldom.DOMNode,
    NOM_NOEUD VARCHAR2,
    VALEUR_NOEUD VARCHAR2)
    AS
    --PERMET D'AJOUTER UN NOEUD AVEC 1 SEULE VALEUR DANS une ROW D'UN XML.
    --UTILE SURTOUT POUR LES CLÉS ÉTRANGÈRES
    domElemAInserer DBMS_XMLDOM.DOMELEMENT;
    NODE dbms_xmldom.DOMNode;
    NODE_TMP dbms_xmldom.DOMNode;
    BEGIN
    domElemAInserer := DBMS_XMLDOM.createElement(XMLDOMDOC, NOM_NOEUD) ;
    NODE := DBMS_XMLDOM.MAKENODE(domElemAInserer); --cast
    NODE := DBMS_XMLDOM.APPENDCHILD(NODE_ROW,NODE);
    NODE_TMP := DBMS_XMLDOM.MAKENODE(DBMS_XMLDOM.CREATETEXTNODE(XMLDOMDOC, VALEUR_NOEUD ) );
    NODE := DBMS_XMLDOM.APPENDCHILD(NODE,NODE_TMP );
    END;

    Hi Everybody!
    I'm working with Oracle 9.2.0.5 on Microsoft Windows Server 2003 Enterprise Edition.
    The server (a test server) is a Pentium 4 2.8 GHz, 1GB of RAM.
    I use a procedure called PARITOP_TRAITERXMLRESULTMASSE to insert the data contained in the pXMLDOC clob parameter in the table pTABLENAME. (You can see the format of the XML document below). The first step on this procedure is to verify that the XML document is not empty. If not, the procedure needs to add a node in the document, in every <ROW> tag. This added node is named “RST_ID”. It’s the foreign key of each record. I can retrieve the value of each <RST_ID> node in an other table in which the data has been previously added (by the calling procedure). When each of the <ROW> elements has been treated, the PARITOP_INSERTXML procedure is called. This procedure uses DBMS_XMLSAVE.INSERTXML to insert the data contained in the XML document in the specified table.
    (Below, you can see the code of my procedures.)
    With this information, can you tell me why this treatment is very very very slow with a large XML document and how I can improve it?
    Thank you for your help!
    Anne-Marie
    CREATE OR REPLACE PROCEDURE "PARITOP_TRAITERXMLRESULTMASSE" (
    pPRC_ID IN PARITOP_PARC.PRC_ID%TYPE,
    pRST_MONDE IN PARITOP_RESULTAT.RST_MONDE%TYPE,
    pXMLDOC IN CLOB,
    pTABLENAME IN VARCHAR2)
    AS
    Objectif :Insérer le contenu du XML passé en paramètre (pXMLDOC) à la table passée en paramètre (pTABLENAME)
    La table passée en paramètre doit être une table ayant comme clé étrangère le champs "RST_ID" .
    (Le noeud RST_ID est donc ajouté à tous les document XML. Ce rst_id est
    déterminé à partir de la table PARITOP_RESULTAT grâce à pPRC_ID et
    pRstMonde fournis en paramètre)
    result_doc CLOB;
    XMLDOMDOC XDB.DBMS_XMLDOM.DOMDOCUMENT;
    NODE_ROWSET DBMS_XMLDOM.DOMNODE;
    NODE_ROW DBMS_XMLDOM.DOMNODE;
    vUE_ID PARITOP_RESULTAT.UE_ID%TYPE;
    vRST_ID PARITOP_RESULTAT.RST_ID%TYPE;
    nodeList DBMS_XMLDOM.DOMNODELIST;
    BEGIN
    BEGIN
    vUE_ID := 0;
    vRST_ID := 0;
    XMLDOMDOC := DBMS_XMLDOM.NEWDOMDOCUMENT(pXMLDOC);
    IF NOT GESTXML_PKG.FN_PARITOP_DOCUMENT_IS_NULL(XMLDOMDOC) THEN
    NODE_ROWSET := DBMS_XMLDOM.item(DBMS_XMLDOM.GETCHILDNODES (DBMS_XMLDOM.MAKENODE(XMLDOMDOC)),0);
    for i in 0..dbms_xmldom.getLength(DBMS_XMLDOM.getchildnodes(NODE_ROWSET))-1 loop
    NODE_ROW := DBMS_XMLDOM.ITEM(DBMS_XMLDOM.GETCHILDNODES(NODE_ROWSET), i) ;
    nodeList := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(DBMS_XMLDOM.makeelement(NODE_ROW) , 'UE_ID');
    IF vUE_ID <> DBMS_XMLDOM.GETNODEVALUE(DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.ITEM(nodeList, 0))) THEN
    vUE_ID := DBMS_XMLDOM.GETNODEVALUE(DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.ITEM(nodeList, 0)));
    --on ramasse le rst_id
    SELECT RST_ID INTO vRST_ID
    FROM PARITOP_RESULTAT RST
    WHERE RST.PRC_ID = pPRC_ID
    AND RST.UE_ID = vUE_ID
    AND RST.RST_MONDE = pRST_MONDE
    AND RST_A_SUPPRIMER = 0;
    END IF;
    GESTXML_PKG.PARITOP_ADDNODETOROW(XMLDOMDOC, NODE_ROW, 'RST_ID', vRST_ID);
    end loop;
    RESULT_DOC := ' '; --à garder, pour ne pas que ca fasse d'erreur lors du WriteToClob.
    dbms_xmldom.writeToClob(DBMS_XMLDOM.MAKENODE(XMLDOMDOC), RESULT_DOC);
    --Insertion du document XML dans la table "tableName"
    GESTXML_PKG.PARITOP_INSERTXML(RESULT_DOC, pTABLENAME);
    DBMS_XMLDOM.FREEDOCUMENT( XMLDOMDOC);
    end if;
    EXCEPTION
    […exception treatement…]
    END;
    END;
    The format of a XML clob is :
    <ROWSET>
    <ROW>
    <PRC_ID>193</PRC_ID>
    <UE_ID>8781</UE_ID>
    <VEN_ID>6223</VEN_ID>
    <RST_MONDE>0</RST_MONDE>
    <CMP_SELMAN>0</CMP_SELMAN>
    <CMP_INDICESELECTION>92.307692307692307</CMP_INDICESELECTION>
    <CMP_PVRES>94900</CMP_PVRES>
    <CMP_PVAJUSTE>72678.017699115066</CMP_PVAJUSTE>
    <CMP_PVAJUSTEMIN>72678.017699115095</CMP_PVAJUSTEMIN>
    <CMP_PVAJUSTEMAX>72678.017699115037</CMP_PVAJUSTEMAX>
    <CMP_PV>148000</CMP_PV>
    <CMP_VALROLE>129400</CMP_VALROLE>
    <CMP_PVRESECART>4790</CMP_PVRESECART>
    <CMP_PVRHAB>101778.01769911509</CMP_PVRHAB>
    <CMP_UTILISE>1</CMP_UTILISE>
    <CMP_TVM>1</CMP_TVM>
    <CMP_PVA>148000</CMP_PVA>
    </ROW>
    <ROW>
    <PRC_ID>193</PRC_ID>
    <UE_ID>8781</UE_ID>
    <VEN_ID>6235</VEN_ID>
    <RST_MONDE>0</RST_MONDE>
    <CMP_SELMAN>0</CMP_SELMAN>
    <CMP_INDICESELECTION>76.92307692307692</CMP_INDICESELECTION>
    <CMP_PVRES>117800</CMP_PVRES>
    <CMP_PVAJUSTE>118080</CMP_PVAJUSTE>
    <CMP_PVAJUSTEMIN>118080</CMP_PVAJUSTEMIN>
    <CMP_PVAJUSTEMAX>118080</CMP_PVAJUSTEMAX>
    <CMP_PV>172000</CMP_PV>
    <CMP_VALROLE>134800</CMP_VALROLE>
    <CMP_PVRESECART>0</CMP_PVRESECART>
    <CMP_PVRHAB>147180</CMP_PVRHAB>
    <CMP_UTILISE>1</CMP_UTILISE>
    <CMP_TVM>1</CMP_TVM>
    <CMP_PVA>172000</CMP_PVA>
    </ROW>
    </ROWSET>
    PARITOP_COMPARABLE TABLE :
    RST_ID NUMBER(10) NOT NULL,
    VEN_ID NUMBER(10) NOT NULL,
    CMP_SELMAN NUMBER(1) NOT NULL,
    CMP_UTILISE NUMBER(1) NOT NULL,
    CMP_INDICESELECTION FLOAT(53) NOT NULL,
    CMP_PVRES FLOAT(53) NULL,
    CMP_PVAJUSTE FLOAT(53) NULL,
    CMP_PVRHAB FLOAT(53) NULL,
    CMP_TVM FLOAT(53) NULL
    ROCEDURE PARITOP_INSERTXML (xmlDoc IN clob, tableName IN VARCHAR2)
    AS
    insCtx DBMS_XMLSave.ctxType;
    rowss number;
    BEGIN
    --permet d'insérer les champs du XML dans la table passée en paramètre.
    --il suffit que les champs XML aient le même nom que les champs de la table
    BEGIN
    insCtx := DBMS_XMLSave.newContext(tableName); -- get context handle
    DBMS_XMLSAVE.SETDATEFORMAT( insCtx, 'yyyy-MM-dd HH:mm:ss');--attention, case sensitive
    DBMS_XMLSAVE.setIgnoreCase(insCtx, 1);
    rowss := DBMS_XMLSAVE.INSERTXML(insCtx , xmlDoc);
    DBMS_XMLSave.closeContext(insCtx);
    EXCEPTION
    […]
    END;
    END;
    PROCEDURE PARITOP_ADDNODETOROW (
    XMLDOMDOC DBMS_XMLDOM.DOMDOCUMENT,
    NODE_ROW dbms_xmldom.DOMNode,
    NOM_NOEUD VARCHAR2,
    VALEUR_NOEUD VARCHAR2)
    AS
    --PERMET D'AJOUTER UN NOEUD AVEC 1 SEULE VALEUR DANS une ROW D'UN XML.
    --UTILE SURTOUT POUR LES CLÉS ÉTRANGÈRES
    domElemAInserer DBMS_XMLDOM.DOMELEMENT;
    NODE dbms_xmldom.DOMNode;
    NODE_TMP dbms_xmldom.DOMNode;
    BEGIN
    domElemAInserer := DBMS_XMLDOM.createElement(XMLDOMDOC, NOM_NOEUD) ;
    NODE := DBMS_XMLDOM.MAKENODE(domElemAInserer); --cast
    NODE := DBMS_XMLDOM.APPENDCHILD(NODE_ROW,NODE);
    NODE_TMP := DBMS_XMLDOM.MAKENODE(DBMS_XMLDOM.CREATETEXTNODE(XMLDOMDOC, VALEUR_NOEUD ) );
    NODE := DBMS_XMLDOM.APPENDCHILD(NODE,NODE_TMP );
    END;

  • Approach to parse large number of XML files into the relational table.

    We are exploring the option of XML DB for processing a large number of files coming same day.
    The objective is to parse the XML file and store in multiple relational tables. Once in relational table we do not care about the XML file.
    The file can not be stored on the file server and need to be stored in a table before parsing due to security issues. A third party system will send the file and will store it in the XML DB.
    File size can be between 1MB to 50MB and high performance is very much expected other wise the solution will be tossed.
    Although we do not have XSD, the XML file is well structured. We are on 11g Release 2.
    Based on the reading this is what my approach.
    1. CREATE TABLE XML_DATA
    (xml_col XMLTYPE)
    XMLTYPE xml_col STORE AS SECUREFILE BINARY XML;
    2. Third party will store the data in XML_DATA table.
    3. Create XMLINDEX on the unique XML element
    4. Create views on XMLTYPE
    CREATE OR REPLACE FORCE VIEW V_XML_DATA(
       Stype,
       Mtype,
       MNAME,
       OIDT
    AS
       SELECT x."Stype",
              x."Mtype",
              x."Mname",
              x."OIDT"
       FROM   data_table t,
              XMLTABLE (
                 '/SectionMain'
                 PASSING t.data
                 COLUMNS Stype VARCHAR2 (30) PATH 'Stype',
                         Mtype VARCHAR2 (3) PATH 'Mtype',
                         MNAME VARCHAR2 (30) PATH 'MNAME',
                         OIDT VARCHAR2 (30) PATH 'OID') x;
    5. Bulk load the parse data in the staging table based on the index column.
    Please comment on the above approach any suggestion that can improve the performance.
    Thanks
    AnuragT

    Thanks for your response. It givies more confidence.
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    Example XML
    <SectionMain>
    <SectionState>Closed</SectionState>
    <FunctionalState>CP FINISHED</FunctionalState>
    <CreatedTime>2012-08</CreatedTime>
    <Number>106</Number>
    <SectionType>Reel</SectionType>
    <MachineType>CP</MachineType>
    <MachineName>CP_225</MachineName>
    <OID>99dd48cf-fd1b-46cf-9983-0026c04963d2</OID>
    </SectionMain>
    <SectionEvent>
    <SectionOID>99dd48cf-2</SectionOID>
    <EventName>CP.CP_225.Shredder</EventName>
    <OID>b3dd48cf-532d-4126-92d2</OID>
    </SectionEvent>
    <SectionAddData>
    <SectionOID>99dd48cf2</SectionOID>
    <AttributeName>ReelVersion</AttributeName>
    <AttributeValue>4</AttributeValue>
    <OID>b3dd48cf</OID>
    </SectionAddData>
    - <SectionAddData>
    <SectionOID>99dd48cf-fd1b-46cf-9983</SectionOID>
    <AttributeName>ReelNr</AttributeName>
    <AttributeValue>38</AttributeValue>
    <OID>b3dd48cf</OID>
    <BNCounter>
    <SectionID>99dd48cf-fd1b-46cf-9983-0026c04963d2</SectionID>
    <Run>CPFirstRun</Run>
    <SortingClass>84</SortingClass>
    <OutputStacker>D2</OutputStacker>
    <BNCounter>54605</BNCounter>
    </BNCounter>
    I was not aware of Virtual column but looks like we can use it and avoid creating views by just inserting directly into
    the staging table using virtual column.
    Suppose OID id is the unique identifier of each XML FILE and I created virtual column
    CREATE TABLE po_Virtual OF XMLTYPE
    XMLTYPE STORE AS BINARY XML
    VIRTUAL COLUMNS
    (OID_1 AS (XMLCAST(XMLQUERY('/SectionMain/OID'
    PASSING OBJECT_VALUE RETURNING CONTENT)
    AS VARCHAR2(30))));
    1. My question is how then I will write this query by NOT USING COLMUN XML_COL
    SELECT x."SECTIONTYPE",
    x."MACHINETYPE",
    x."MACHINENAME",
    x."OIDT"
    FROM po_Virtual t,
    XMLTABLE (
    '/SectionMain'
    PASSING t.xml_col                          <--WHAT WILL PASSING HERE SINCE NO XML_COL
    COLUMNS SectionType VARCHAR2 (30) PATH 'SectionType',
    MachineType VARCHAR2 (3) PATH 'MachineType',
    MachineName VARCHAR2 (30) PATH 'MachineName',
    OIDT VARCHAR2 (30) PATH 'OID') x;
    2. Insetead of creating the view then Can I do
    insert into STAGING_table_yyy ( col1 ,col2,col3,col4,
    SELECT x."SECTIONTYPE",
    x."MACHINETYPE",
    x."MACHINENAME",
    x."OIDT"
    FROM xml_data t,
    XMLTABLE (
    '/SectionMain'
    PASSING t.xml_col                         <--WHAT WILL PASSING HERE SINCE NO XML_COL
    COLUMNS SectionType VARCHAR2 (30) PATH 'SectionType',
    MachineType VARCHAR2 (3) PATH 'MachineType',
    MachineName VARCHAR2 (30) PATH 'MachineName',
    OIDT VARCHAR2 (30) PATH 'OID') x
    where oid_1 = '99dd48cf-fd1b-46cf-9983';<--VIRTUAL COLUMN
    insert into STAGING_table_yyy ( col1 ,col2,col3
    SELECT x."SectionOID",
    x."EventName",
    x."OIDT"
    FROM xml_data t,
    XMLTABLE (
    '/SectionMain'
    PASSING t.xml_col                         <--WHAT WILL PASSING HERE SINCE NO XML_COL
    COLUMNS SectionOID PATH 'SectionOID',
    EventName VARCHAR2 (30) PATH 'EventName',
    OID VARCHAR2 (30) PATH 'OID',
    ) x
    where oid_1 = '99dd48cf-fd1b-46cf-9983';<--VIRTUAL COLUMN
    Same insert for other tables usind the OID_1 virtual coulmn
    3. Finaly Once done how can I delete the XML document from XML.
    If I am using virtual column then I beleive it will be easy
    DELETE table po_Virtual where oid_1 = '99dd48cf-fd1b-46cf-9983';
    But in case we can not use the Virtual column how we can delete the data
    Thanks in advance
    AnuragT

  • PROBLEM IN EXPORTING DATA FROM A RELATIONAL TABLE TO ANOTHER RELATIONAL TAB

    Hi,
    While trying to export data from a source table to a target table, problem occurs with loading the data in the work table(SrcSet0)[As shown in the operator]. The Work Table has been dropped and created successfully, the problem is coming with loading the data( in this work table(SrcSet0)). The error details as mentioned below. Please advise:-
    ODI-1227: Task SrcSet0 (Loading) fails on the source ORACLE connection ORACLE_SOURCE.
    Caused By: java.sql.SQLException: SQL string is not Query
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1442)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3752)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3806)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1667)
         at oracle.odi.query.JDBCTemplate.executeQuery(JDBCTemplate.java:189)
         at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:89)
         at oracle.odi.runtime.agent.execution.sql.SQLDataProvider.readData(SQLDataProvider.java:1)
         at oracle.odi.runtime.agent.execution.DataMovementTaskExecutionHandler.handleTask(DataMovementTaskExecutionHandler.java:67)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2906)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2609)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:537)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:453)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:1740)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:338)
         at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:214)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:272)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:263)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:822)
         at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:123)
         at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
         at java.lang.Thread.run(Thread.java:662)
    Thanks
    Anindya

    Hi actdi,
    This is my KM_IKM SQL Incremental Update.xml code:-
    and I have find it(for (int i=odiRef.getDataSetMin(); i <= odiRef.getDataSetMax(); i++)) and high lighted it(Bold Text).
    So, please advise.
    Here is the main part of this code because the code is too long to post.It exceeds maxlength for the msg.
    So here it is:
    <Object class="com.sunopsis.dwg.dbobj.SnpTxtHeader">
    <Field name="Enc" type="java.lang.String">null</Field>
    <Field name="EncKey" type="java.lang.String">null</Field>
    <Field name="ITxt" type="com.sunopsis.sql.DbInt"><![CDATA[1695003]]></Field>
    <Field name="ITxtOrig" type="com.sunopsis.sql.DbInt"><![CDATA[102]]></Field>
    <Field name="SqlIndGrp" type="java.lang.String"><![CDATA[2]]></Field>
    <Field name="Txt" type="java.lang.String"><![CDATA[insert into <%=odiRef.getTable("L","INT_NAME","A")%>
    <%=odiRef.getColList("", "[COL_NAME]", ",\n\t", "", "(((INS or UPD) and !TRG) and REW)")%>,
    IND_UPDATE
    *<%for (int i=odiRef.getDataSetMin(); i <= odiRef.getDataSetMax(); i++){%>*
    <%=odiRef.getDataSet(i, "Operator")%>
    select <%=odiRef.getPop("DISTINCT_ROWS")%>
    <%=odiRef.getColList(i,"", "[EXPRESSION]", ",\n\t", "", "(((INS or UPD) and !TRG) and REW)")%>,
    <% if (odiRef.getDataSet(i, "HAS_JRN").equals("1")) { %>
    JRN_FLAG IND_UPDATE
    <%} else {%>
    'I' IND_UPDATE
    <%}%>
    from <%=odiRef.getFrom(i)%>
    where (1=1)
    <%=odiRef.getJoin(i)%>
    <%=odiRef.getFilter(i)%>
    <%=odiRef.getJrnFilter(i)%>
    <%=odiRef.getGrpBy(i)%>
    <%=odiRef.getHaving(i)%>
    <%}%>
    ]]></Field>
    </Object>
    <Object class="com.sunopsis.dwg.dbobj.SnpLineTrt">
    <Field name="AlwaysExe" type="java.lang.String"><![CDATA[0]]></Field>

  • XML stored as object relational fails

    We are looking at implementing a system to store Universal Business Language (UBL) 1.0 XML invoices in an XMLType column in 10g. I've registered all the requisite schemas (the UBL invoice comprises a rather complicated hierarchy of 19 individual namespaces), but when I come to create the table:
    CREATE TABLE UBLInvoices (
    invoice_id NUMBER,
    invoice_spec XMLTYPE)
    XMLTYPE invoice_spec STORE AS OBJECT RELATIONAL
    XMLSCHEMA "Invoice-1.0"
    ELEMENT "Invoice";
    I get an error message to the effect that a table with more than 1000 columns cannot be created. I can create the table using CLOB storage (STORE AS CLOB) without any problems. Is there a limit to the complexity of typed XMLType column schema? Is there any workaround?

    As A Non says, why is it unacceptable?
    It's only unacceptable to you, but it's not unacceptable XML. The standard of XML does not require a display format as the purpose of XML is to define a structure of data, not to present itself nicely to you on the screen.
    If you want to prettify your XML, that's up to you, but optimised XML data does not have formatting, which takes up additional and unnecessary storage space.

  • Xml data to abap internal table

    I'm presently working on a interface where data in abap internal table is converted into xml format and placed in the frontend and vice versa.
    I'm through with the first part and in secodn part also I'm able to transfer the data from frontend to Document Object Model(DOM) by parsing but finally am not able to put it into an internal table.
    Please help (Urgent).
    Thanks and regards,
    S.K.Tripathy

    Hi sitakant,
    1. itab --- > xml
       xml ---> itab.
    2. This program will do both.
       (just copy paste in new program)
    3.
    REPORT abc.
    DATA
    DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
    DATA : BEGIN OF itab OCCURS 0,
    a(100) TYPE c,
    END OF itab.
    DATA: xml_out TYPE string .
    DATA : BEGIN OF upl OCCURS 0,
           f(255) TYPE c,
           END OF upl.
    DATA: xmlupl TYPE string .
    FIRST PHASE
    FIRST PHASE
    FIRST PHASE
    Fetch Data
    SELECT * FROM t001 INTO TABLE t001.
    XML
    CALL TRANSFORMATION ('ID')
    SOURCE tab = t001[]
    RESULT XML xml_out.
    Convert to TABLE
    CALL FUNCTION 'HR_EFI_CONVERT_STRING_TO_TABLE'
      EXPORTING
        i_string         = xml_out
        i_tabline_length = 100
      TABLES
        et_table         = itab.
    Download
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filetype = 'BIN'
        filename = 'd:\xx.xml'
      TABLES
        data_tab = itab.
    SECOND PHASE
    SECOND PHASE
    SECOND PHASE
    BREAK-POINT.
    REFRESH t001.
    CLEAR t001.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename = 'D:\XX.XML'
        filetype = 'BIN'
      TABLES
        data_tab = upl.
    LOOP AT upl.
      CONCATENATE xmlupl upl-f INTO xmlupl.
    ENDLOOP.
    XML
    CALL TRANSFORMATION ('ID')
    SOURCE  XML xmlupl
    RESULT tab = t001[]
    BREAK-POINT.
    regards,
    amit m.

Maybe you are looking for

  • Change Attributes of a single Cell

    Dear Gurus , I made an ALV using OO . In one field i said to field catalogue to be as a Button Style . My requirement now is when a value of my itab is something not to be as a button style . For example a    button style b    button style c    no bu

  • Ssrs 2008 'select all' option to be selected for a parameter

    In a new ssrs 2008 report, the problem is all reports are not selected from the parameter called 'report' when the report runs automatically.  When the report executes, there is nothing displayed in the parameter selection  dropdown box. The user has

  • Fixed width field format in txt file

    I want to create text file for sending to bank. Every row in the text file is of variable length. For Ex: 1st row contains name and a fixed length of 33 char. 2nd row contains company and fixed length of 12 char. Howewer when i download the data usin

  • DB connect failed return code 000256 --- disp_work ended

    Hi Friends, I have installed ides ECC 6 on oracle 10g on windows 2003 server.Now I am unable to start SAP console. While starting the disp+work getting ended. I found form the log that the DB connect failed return code 000256 in dev_disp. snapshot is

  • Inbound File Sequence Number

    Hi, I have a requirement and request your expertise. PI will need to pick up a file from FTP server and would be passed on to SAP via idoc. We have a unique requirement where the SAP would need to check whether the previous file is processed or not b