What is default size of XMLType column?

I have a table with 1 raw type and 1 XMLType column. In the XMLType column I am inserting following XML,
<ocaStatus xmlns="http://xmlbeans.apache.org/ocastatus">
<status>
<statusCode>990</statusCode>
<statusDateclass="sql-date">2010-01-19</statusDate>
<userId>OcaNimsAcf</userId>
<comment>DocumentnotinNIMS</comment>
</status>
<status>
<statusCode>990</statusCode>
<statusDateclass="sql-date">2010-01-19</statusDate>
<userId>OcaNimsAcf</userId>
<comment>DocumentnotinNIMS</comment>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-09-16</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-09-16</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-09-16</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-29</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-29</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-28</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-28</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-27</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-26</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-25</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-22</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-22</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-22</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-22</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-22</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-21</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-21</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-21</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-21</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-21</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-20</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-20</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-20</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>306</statusCode>
<statusDateclass="sql-date">2008-04-21</statusDate>
<userId>u0075970</userId>
</status>
<status>
<statusCode>301</statusCode>
<statusDateclass="sql-date">2008-02-05</statusDate>
<userId>DMS_WORKFLOW</userId>
<comment></comment>
</status>
<status>
<statusCode>990</statusCode>
<statusDateclass="sql-date">2010-01-17</statusDate>
<userId>OcaNimsAcf</userId>
<comment>Comparedfornimsacf</comment>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-09-16</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-09-16</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-09-16</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-29</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-29</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-28</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-28</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-27</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-26</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-25</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-22</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-22</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-22</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-22</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-22</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-21</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-21</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-21</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-21</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-21</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-20</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-20</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>501</statusCode>
<statusDateclass="sql-date">2008-08-20</statusDate>
<userId>oca_scheduled_job</userId>
</status>
<status>
<statusCode>306</statusCode>
<statusDateclass="sql-date">2008-04-21</statusDate>
<userId>u0075970</userId>
</status>
<status>
<statusCode>301</statusCode>
<statusDateclass="sql-date">2008-02-05</statusDate>
<userId>DMS_WORKFLOW</userId>
<comment></comment>
</status>
</ocaStatus>
The xml is very long. For inserting into the table I am using xmlparse() function to get XMLType.
While doing this I am getting ORA-01704: string literal too long error. It says can accommodate at the most 4000 characters.
I guess XMLType is stored as a CLOB by default.So it should allow more than 4000 characters.
How can I store xml with more than 4000 characters.
Thanks.

XMLParse is a SQL function, so you can't use a string literal longer than 4000 chars.
Instead, you may declare a PL/SQL VARCHAR2 variable, which can hold up to 32k characters, and then use the XMLType constructor :
DECLARE
xmlstr VARCHAR2(32767) := '<xml string here>';
xmldoc xmltype;
BEGIN
xmldoc := xmltype(xmlstr);
INSERT INTO your_table(xml_data) VALUES(xmldoc);
END;For strings longer than 32k, you'll probably have to load it from a file.

Similar Messages

  • To increase the XMLtype column data length

    Hi ,
    I have created a Table with an XMLtype column , when I am checking the data length it is showing only 2000.
    How can I increase the length.
    DBMS_METADATA.GET_DDL('TABLE','CC_EVENT_MESSAGES','UNS_STAGING_DEV5')
      CREATE TABLE "UNS_STAGING_DEV5"."CC_EVENT_MESSAGES"
       (    "SRC_SYSTEM_CD" VARCHAR2(10) NOT NULL ENABLE,
            "SRC_SEQUENCE_NUM" NUMBER NOT NULL ENABLE,
            "SRC_EVENT_NAME" VARCHAR2(255) NOT NULL ENABLE,
            "SRC_EVENT_XSD_NAME" VARCHAR2(255) NOT NULL ENABLE,
            "SRC_EVENT_DATE" DATE NOT NULL ENABLE,
            "INSERT_TS" TIMESTAMP (6) NOT NULL ENABLE,
            "PROCESSED_TS" TIMESTAMP (6),
            "STAGING_NUM" NUMBER NOT NULL ENABLE,
            "MESSAGE_STATE" VARCHAR2(10) NOT NULL ENABLE,
            "MESSAGE_FRAME" "SYS"."XMLTYPE"  NOT NULL ENABLE
       ) SEGMENT CREATION IMMEDIATE
      PCTFREE 0 PCTUSED 0 INITRANS 1 MAXTRANS 255
    NOCOMPRESS LOGGING
      STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "UNS_STAGING_DEV5"
    XMLTYPE COLUMN "MESSAGE_FRAME" STORE AS BASICFILE CLOB (
      TABLESPACE "UNS_STAGING_DEV5" ENABLE STORAGE IN ROW CHUNK 8192 RETENTION
      CACHE
      STORAGE(INITIAL 65536 NEXT 65536 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT))
       CACHE
    SQL> select OWNER,TABLE_NAME,column_name,data_type,data_length from dba_tab_columns where DATA_TYPE like '%XMLTYPE' and owner not in ('SYS','SYSTEM','XDB');
    OWNER                TABLE_NAME           COLUMN_NAME     DATA_TYPE  DATA_LENGTH
    UNS_STAGING_DEV5     CC_EVENT_MESSAGES    MESSAGE_FRAME   XMLTYPE           2000

    I have created a Table with an XMLtype column , when I am checking the data length it is showing only 2000.
    Don't rely on this value, it's wrong.
    XMLType datatype inherits the properties of its underlying LOB storage, in the present case CLOB, which can store TBs of data.

  • [11g] most efficient way to calculate size of xmltype type column

    I need to check the current size of some xmltype column in a BIU trigger.
    I don't think it's good to use
      length(:new.xml_data.GetStringVal());
    or
      dbms_lob.GetLength(:new.xml_data.GetClobVal());
    What's the most efficient way to get the storage size?
    I don't need the string serialized size.
    It could also be the internal storage size (incl. administration data overhead).
    - thanks!
    regards,
    Frank

    > May I ask for what reason you need to know it?
    I need to handle very large XML document output, which currently hits the internal xmltype limitation of 4GByte, when aggregating XML document fragments for this.
    > You'll get a relevant answer if you give us relevant information :
    > - exact db version
    SELECT * FROM PRODUCT_COMPONENT_VERSION;
    product
    version
    status
    1
    NLSRTL
    11.2.0.3.0
    Production
    2
    Oracle Database 11g Enterprise Edition
    11.2.0.3.0
    64bit Production
    3
    PL/SQL
    11.2.0.3.0
    Production
    4
    TNS for Linux:
    11.2.0.3.0
    Production
    > - DDL of your table
    > XML stored as XMLType datatype can use different storage models, depending on the version.
    I don't use dedicated storage clause.
    But i am hitting the problem already for aggregation into some xmltype variable in PL/SQL
    - BEFORE writing back to a result table.
    Can i avoid such problems, when writing to a table DIRECTLY w/o intermediate xmltype PL/SQL variable
    - depending on the storage clause?
    The reason why asking how to get the size of some xmltype (in table column and/or in PL/SQL variable) is, that i am thinking of a threshold detection.
    In case threshold is reached: outsource XML fragment so far to some separate CLOB storage, and insert a smaller meta-information reference representing that in the output document.
    Finally leave up to the client system to use <xs:include> (or alike) to construct the complete document.
    rgds,
    Frank

  • Find size of table with XMLTYPE column STORE AS BINARY XML

    Hi,
    I have a table with structure as:
    CREATE TABLE XML_TABLE_1
    ID NUMBER NOT NULL,
    SOURCE VARCHAR2(255 CHAR) NOT NULL,
    XML_TEXT SYS.XMLTYPE,
    CREATION_DATE TIMESTAMP(6) NOT NULL
    XMLTYPE XML_TEXT STORE AS BINARY XML (
    TABLESPACE Tablespace1_LOB
    DISABLE STORAGE IN ROW
    CHUNK 16384
    RETENTION
    CACHE READS
    NOLOGGING)
    ALLOW NONSCHEMA
    DISALLOW ANYSCHEMA
    TABLESPACE Tablespace2_DATA
    - So HOW do I find the total size occupied by this table. Does BINARY storage work as LOB storage. i.e. I need to consider USER_LOBS as well for this.
    OR foll. will work
    select segment_name as tablename, sum(bytes/ (1024 * 1024 * 1024 )) as tablesize_in_GB
    From dba_segments
    where segment_name = 'XML_TABLE_1'
    and OWNER = 'SCHEMANAME'
    group by segment_name ;
    - Also if I am copying it to another table of same structure as:
    Insert /*+ append */ into XML_TABLE_2 Select * from XML_TABLE_1.
    Then how much space in ROllbackSegment do I need. Is it equal to the size of the table XML_TABLE_1?
    Thanks..

    I think foll query calculates it right while including the LOB storage as:
    SELECT SUM(bytes)/1024/1024/1024 gb
    FROM dba_segments
    WHERE (owner = 'SCHEMA_NAME' and
    segment_name = 'TABLE_NAME')
    OR (owner, segment_name) IN (
    SELECT owner, segment_name
    FROM dba_lobs
    WHERE owner = 'SCHEMA_NAME'
    AND table_name = 'TABLE_NAME')
    It's 80 GB for our Table with XMLType Column.
    But for the second point:
    Do we need 80GB of UNDO/ROLLBACK Segment for performing:
    Insert /*+ append */ into TableName1 Select * from TableName;
    Thanks..

  • What is the default size of icons on desktop?

    For some reason after installing an application update all the icons on my desktop are now 16X16. What was the default size that came with the OS and what would have changed that setting?

    48x48 is the default. I don't know why the setting might have changed, though.

  • LPX-00004 - Problems while inserting xml files in a xmltype column

    I've faced two problems while trying to insert xml files into my table containing a xmltype column:
    create table xml_test (id number(20),content xmltype)
    I use following java code for writing xml docs into db:
         conn.setAutoCommit(false);
         OraclePreparedStatement stmt = (OraclePreparedStatement)
              conn.prepareStatement("INSERT INTO xml_test (id,content) VALUES(?,?)");
         File file = new File(file1);
         InputStream in1 = new FileInputStream(file1);
         Reader r1 = new BufferedReader(new InputStreamReader(in1, "UTF-8"));
         int len = 0;
         StringBuffer text = new StringBuffer();
         while ((len = r1.read()) != -1) {
              text.append((char) len);
         in1.close();
         r1.close();
         XMLType poXML1 = XMLType.createXML(conn, text.toString());
         for (int i = 1; i <= 1; i++) {
              stmt.setInt(1, i);
              stmt.setObject(2, poXML1);
              stmt.execute();
         conn.commit();
    1. problem: occures only if a xml schema has been assoicated to the specific xmltype column. it seems that the length of a specific xml tag in the document is limited. but why?
    java.sql.SQLException: ORA-22814: attribute or element value is larger than specified in type
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
         at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:656)
         at test.insertXML(test.java:84)
         at test.main(test.java:261)
    hier the xml-schema of the xmltype column "content":
    <?xml version="1.0" encoding="UTF-8"?>
    <!--W3C Schema generated by XML Spy v4.4 U (http://www.xmlspy.com)-->
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
         <xs:element name="AUTOR-ID" type="xs:string"/>
         <xs:element name="BODY" type="xs:string"/>
         <xs:element name="CONTENT">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="METADATEN"/>
                        <xs:element ref="BODY"/>
                   </xs:sequence>
                   <xs:attribute name="content-id" type="xs:string" use="required"/>
              </xs:complexType>
         </xs:element>
         <xs:element name="DATUM" type="xs:string"/>
         <xs:element name="KEYWORD" type="xs:string"/>
         <xs:element name="METADATEN">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="DATUM"/>
                        <xs:element ref="TITEL" maxOccurs="unbounded"/>
                        <xs:element ref="KEYWORD" maxOccurs="unbounded"/>
                        <xs:element ref="AUTOR-ID"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="TITEL" type="xs:string"/>
    </xs:schema>
    2. problem: hier i have no idea what is happening ... please help
    java.sql.SQLException: ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00004: internal error "MultiChar overflow"
    Error at line 61
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
         at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:656)
         at test.insertXML(test.java:53)
         at test.main(test.java:259)

    It's hard for me to tell you more without seeing your instance data, but for problem #1, if you look at the underlying SQL types being generated by your schema, you will see that the default SQL mapping for a "string" in your schema is a VARCHAR2(4000) (and I believe this would be only 2000 for a varying width character set like UTF8).
    You can specify that you wish this column to be mapped as a CLOB in your schema if this is the problem. Also note that there is a 64K limit on the size of an individual node in XMLType.

  • Issues with using XMLType indexes against a table with XMLType column

    I am attempting to use an XMLIndex with a Structured Component and not having too much luck. Not much data in metalink nor is the documentation very helpful:
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10492/xdb_indexing.htm#BCGHGIGC
    The table DDL is as follows:
    CREATE TABLE ECI_SCHEMA.REV_ITEM_EARN_DTL_VIRTUAL(
    REV_ITEM_EARN_DTL_ID_NBR NUMBER(16,0) NOT NULL,
    UNIQ_MSG_ID_NBR VARCHAR2(50) NOT NULL,
    REV_ITEM_BILL_DTL_ID_NBR NUMBER(16,0),
    PLAN_RACN_NBR NUMBER(10,0) NOT NULL,
    INV_DTL_IMG SYS.XMLType NOT NULL,
    NON_INV_DTL_IMG BLOB NOT NULL,
    PART_KEY_CD GENERATED ALWAYS AS (MOD(PLAN_RACN_NBR,5)) VIRTUAL,
    LAST_UPDT_TMSTP TIMESTAMP(6) NOT NULL,
    INV_ID_NBR NUMBER(16,0),
    ITEM_STATUS_CD VARCHAR2(1) DEFAULT 'A' NOT NULL
    LOB (NON_INV_DTL_IMG) STORE AS NON_IDI_LOB (CHUNK 8192 PCTVERSION 10 CACHE)
    TABLESPACE ECI_DATA
    PARTITION BY RANGE (PART_KEY_CD)
    PARTITION RIED_DAY0_PART
    VALUES LESS THAN (1)
    TABLESPACE ECI_DATA
    PARTITION RIED_DAY1_PART
    VALUES LESS THAN (2)
    TABLESPACE ECI_DATA
    PARTITION RIED_DAY2_PART
    VALUES LESS THAN (3)
    TABLESPACE ECI_DATA
    PARTITION RIED_DAY3_PART
    VALUES LESS THAN (4)
    TABLESPACE ECI_DATA
    PARTITION RIED_MAXVAL_PART
    VALUES LESS THAN (MAXVALUE)
    TABLESPACE ECI_DATA
    XMLTYPE COLUMN "INV_DTL_IMG" STORE AS OBJECT RELATIONAL
    XMLSCHEMA "someXdbDocument.xsd"
    ELEMENT "revenueInvoice"
    According to the documentation, I should be able to create a structured XMLIndex on the XMLType column with the following syntax:
    SQL> create index eci_schema.rev_item_earn_dtl_virt_xmlix on eci_schema.rev_item_earn_dtl_virtual
    2 (INV_DTL_IMG)
    3 INDEXTYPE IS XDB.XMLIndex
    4 parameters ('PATH TABLE RIED_PATH_TABLE')
    5 local;
    When I do this, I get the following error:
    create index eci_schema.rev_item_earn_dtl_virt_xmlix on eci_schema.rev_item_earn_dtl_virtual
    ERROR at line 1:
    ORA-29958: fatal error occurred in the execution of ODCIINDEXCREATE routine
    ORA-30959: The indexed column is not stored in CLOB.
    What am I doing wrong? Based on the Oracle documentation, I was under the impression that 11.2 XMLIndex would work with Object Relational storage. Is this not the case?

    CREATE INDEX ECI_SCHEMA.REV_ITEM_EARN_DTL_IX7
           ON ECI_SCHEMA.REV_ITEM_EARN_DTL
                      extractValue(inv_dtl_img, '/revenueInvoice/service/transportation/mstrTrkngNbr')
    TABLESPACE ECI_REV_ITEM_EARN_DTL_IX7_ITS
    LOGGING
    PARALLEL(DEGREE 8 INSTANCES 1)
    LOCAL
    /Elements that occur at most once in each document can be indexed using extractValue(). Despite the fact that the index appears to be a functional index, when we create the index we automatically re-write the create index into a normal btree index on the column that contains the value for the element identified by the xpath.
    Eg in the case of a functional index based on extractValue, defined on XMLType using Object relational storage, with an xpath that identifies a node that occurs at most once in each document is not a functional index, it's re-written into a plain old vanilla btree index. You can actually check this by looking in the system tables
    Eg
    SQL> connect system/oracle
    Connected.
    SQL> select table_name, index_name from all_indexes where owner = 'OE' and table_name = 'PURCHASEORDER';
    TABLE_NAME                     INDEX_NAME
    PURCHASEORDER                  LINEITEM_TABLE_MEMBERS
    PURCHASEORDER                  ACTION_TABLE_MEMBERS
    PURCHASEORDER                  SYS_C0011037
    SQL> alter session set current_schema = OE
      2  /
    Session altered.
    SQL> create unique index PO_REF_INDEX on PURCHASEORDER (extractValue(object_value,'/PurchaseOrder/Reference'));
    Index created.
    SQL> set lines 250
    SQL> select index_name, index_type from all_indexes where owner = 'OE' and table_name = 'PURCHASEORDER';
    INDEX_NAME                     INDEX_TYPE
    PO_REF_INDEX                   NORMAL
    LINEITEM_TABLE_MEMBERS         NORMAL
    ACTION_TABLE_MEMBERS           NORMAL
    SYS_C0011037                   NORMAL
    SQL> select * from dba_ind_expressions where table_name = 'PURCHASEORDER' and index_owner = 'OE'
      2  /
    no rows selectedFrom the above we can see that the index created on extractValue has been re-written in a plain old vanilla BTREE index, and there is no definition for it in dba_ind_expressions So assuming you were able to create the index and insert the data you should find that your index is not a functional index.
    ]

  • XMLType column based on XML Schema: several questions

    Hi,
    I've a table on an oracle db version 10.1.0.4 where I stage the xml files containing orders created on a third party's system using BizTalk.
    Although the storage I opted for is based on an XML Schema, defined by this third-party, I am facing big perfomance issues with files bigger than a few hundreds of kBs.
    For instance, a 32Mb file takes more than 2 hours to be processed.
    Now, after reading other threads in this forum and the documentation, my understanding of the problem is that the whole issue is with the correct indexing of the nested tables.
    Here is my current XML Schema definition:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema
                   xmlns:xs="http://www.w3.org/2001/XMLSchema"
                   xmlns:xdb="http://xmlns.oracle.com/xdb"
                   elementFormDefault="qualified"
                   attributeFormDefault="unqualified"
                   xdb:storeVarrayAsTable="true">
         <xs:include schemaLocation="private/Types.xsd"/>
         <xs:element name="PickData">
              <xs:complexType xdb:maintainDOM="false">
                   <xs:sequence>
                        <xs:element name="ProdRun">
                             <xs:complexType xdb:maintainDOM="false">
                                  <xs:sequence>
                                       <xs:element name="Nr" type="xs:int"/>
                                       <xs:element name="Date" type="string8"/>
                                       <xs:element name="Final" type="xs:int"/>
                                       <xs:element name="PickWave" maxOccurs="unbounded">
                                            <xs:complexType xdb:maintainDOM="false">
                                                 <xs:sequence>
                                                      <xs:element name="Nr" type="string10"/>
                                                      <xs:element name="ProdLine" type="string2"/>
                                                      <xs:element name="TourSeq" type="xs:int"/>
                                                      <xs:element name="Tour" type="string20"/>
                                                      <xs:element name="Customer" maxOccurs="unbounded">
                                                           <xs:complexType xdb:maintainDOM="false">
                                                                <xs:sequence>
                                                                     <xs:element name="Seq" type="string20"/>
                                                                     <xs:element name="Cust" type="string10"/>
                                                                     <xs:element name="Mod" type="string30"/>
                                                                     <xs:element name="Tod" type="string30"/>
                                                                     <xs:element name="InvOrder" maxOccurs="unbounded">
                                                                          <xs:complexType xdb:maintainDOM="false">
                                                                               <xs:sequence>
                                                                                    <xs:element name="Nr" type="string20"/>
                                                                                    <xs:element name="Item" type="string20"/>
                                                                                    <xs:element name="Qty" type="xs:int"/>
                                                                                    <xs:element name="Priority" type="xs:int"/>
                                                                                    <xs:element name="Reordering" type="xs:int"/>
                                                                                    <xs:element name="DelDate" type="string8"/>
                                                                                    <xs:element name="HlOrder" type="string20"/>
                                                                               </xs:sequence>
                                                                          </xs:complexType>
                                                                          <xs:unique name="InvOrderKey">
                                                                               <xs:selector xpath="InvOrder"/>
                                                                               <xs:field xpath="Nr"/>
                                                                          </xs:unique>
                                                                     </xs:element>
                                                                </xs:sequence>
                                                           </xs:complexType>
                                                           <xs:unique name="CustomerKey">
                                                                <xs:selector xpath="Customer"/>
                                                                <xs:field xpath="Seq"/>
                                                           </xs:unique>
                                                      </xs:element>
                                                 </xs:sequence>
                                            </xs:complexType>
                                            <xs:unique name="PickWaveKey">
                                                 <xs:selector xpath="PickWave"/>
                                                 <xs:field xpath="Nr"/>
                                            </xs:unique>
                                       </xs:element>
                                  </xs:sequence>
                             </xs:complexType>
                             <xs:unique name="ProdRunKey">
                                  <xs:selector xpath="ProdRun"/>
                                  <xs:field xpath="Nr"/>
                             </xs:unique>
                        </xs:element>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
    </xs:schema>
    Here is the included sub-schema:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
              <xsd:simpleType name="string2">
    <xsd:restriction base="xsd:string">
    <xsd:maxLength value="2"/>
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="string5">
    <xsd:restriction base="xsd:string">
    <xsd:maxLength value="5"/>
    </xsd:restriction>
    </xsd:simpleType>
              <xsd:simpleType name="string6">
    <xsd:restriction base="xsd:string">
    <xsd:maxLength value="6"/>
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="string8">
    <xsd:restriction base="xsd:string">
    <xsd:maxLength value="8"/>
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="string10">
    <xsd:restriction base="xsd:string">
    <xsd:maxLength value="10"/>
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="string15">
    <xsd:restriction base="xsd:string">
    <xsd:maxLength value="15"/>
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="string20">
    <xsd:restriction base="xsd:string">
    <xsd:maxLength value="20"/>
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="string30">
    <xsd:restriction base="xsd:string">
    <xsd:maxLength value="30"/>
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="string40">
    <xsd:restriction base="xsd:string">
    <xsd:maxLength value="40"/>
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="string50">
    <xsd:restriction base="xsd:string">
    <xsd:maxLength value="50"/>
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="string250">
                   <xsd:restriction base="xsd:string">
                        <xsd:maxLength value="250"/>
                   </xsd:restriction>
              </xsd:simpleType>
         </xsd:schema>
    The statement for creating my table is
    CREATE TABLE "XML_ORDERS"
    ("ID" NUMBER(7,0) NOT NULL ENABLE,
    "XMLFILE" "SYS"."XMLTYPE" ,
    "INSERTED" DATE DEFAULT sysdate,
    CONSTRAINT "XML_ORDERS_PK" PRIMARY KEY ("ID") USING INDEX ENABLE
    ) XMLTYPE COLUMN XMLFILE STORE AS OBJECT RELATIONAL
    XMLSCHEMA "private/PickData.xsd" ELEMENT "PickData"
    Here is a simple instance document:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <PickData xsi:noNamespaceSchemaLocation="private/PickData.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <ProdRun>
    <Nr>5</Nr>
    <Date>15112005</Date>
    <Final>1</Final>
    <PickWave>
    <Nr>IPW0000017</Nr>
    <ProdLine>01</ProdLine>
    <TourSeq>1</TourSeq>
    <Tour>00000043_078</Tour>
    <Customer>
    <Seq>5</Seq>
    <Cust>100000006</Cust>
    <Mod>FO</Mod>
    <Tod>DDU</Tod>
    <InvOrder>
    <Nr>IIO0000457</Nr>
    <Item>100000036</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000742</HlOrder>
    </InvOrder>
    <InvOrder>
    <Nr>IIO0000459</Nr>
    <Item>100000045</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000742</HlOrder>
    </InvOrder>
    </Customer>
    <Customer>
    <Seq>6</Seq>
    <Cust>100000013</Cust>
    <Mod>FO</Mod>
    <Tod>DDU</Tod>
    <InvOrder>
    <Nr>IIO0000461</Nr>
    <Item>100000036</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000743</HlOrder>
    </InvOrder>
    <InvOrder>
    <Nr>IIO0000463</Nr>
    <Item>100000045</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000743</HlOrder>
    </InvOrder>
    </Customer>
    <Customer>
    <Seq>2</Seq>
    <Cust>100000114</Cust>
    <Mod>FO</Mod>
    <Tod>DDU</Tod>
    <InvOrder>
    <Nr>IIO0000465</Nr>
    <Item>100000036</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000744</HlOrder>
    </InvOrder>
    <InvOrder>
    <Nr>IIO0000467</Nr>
    <Item>100000045</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000744</HlOrder>
    </InvOrder>
    </Customer>
    <Customer>
    <Seq>3</Seq>
    <Cust>100000140</Cust>
    <Mod>FO</Mod>
    <Tod>DDU</Tod>
    <InvOrder>
    <Nr>IIO0000469</Nr>
    <Item>100000036</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000745</HlOrder>
    </InvOrder>
    <InvOrder>
    <Nr>IIO0000471</Nr>
    <Item>100000045</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000745</HlOrder>
    </InvOrder>
    </Customer>
    <Customer>
    <Seq>7</Seq>
    <Cust>100000143</Cust>
    <Mod>FO</Mod>
    <Tod>DDU</Tod>
    <InvOrder>
    <Nr>IIO0000473</Nr>
    <Item>100000036</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000746</HlOrder>
    </InvOrder>
    <InvOrder>
    <Nr>IIO0000475</Nr>
    <Item>100000045</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000746</HlOrder>
    </InvOrder>
    </Customer>
    <Customer>
    <Seq>8</Seq>
    <Cust>100000145</Cust>
    <Mod>FO</Mod>
    <Tod>DDU</Tod>
    <InvOrder>
    <Nr>IIO0000477</Nr>
    <Item>100000036</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000747</HlOrder>
    </InvOrder>
    <InvOrder>
    <Nr>IIO0000479</Nr>
    <Item>100000045</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000747</HlOrder>
    </InvOrder>
    </Customer>
    <Customer>
    <Seq>9</Seq>
    <Cust>100000146</Cust>
    <Mod>FO</Mod>
    <Tod>DDU</Tod>
    <InvOrder>
    <Nr>IIO0000481</Nr>
    <Item>100000036</Item>
    <Qty>20</Qty>
    <Priority>0</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000748</HlOrder>
    </InvOrder>
    <InvOrder>
    <Nr>IIO0000483</Nr>
    <Item>100000045</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000748</HlOrder>
    </InvOrder>
    </Customer>
    <Customer>
    <Seq>4</Seq>
    <Cust>100000147</Cust>
    <Mod>FO</Mod>
    <Tod>DDU</Tod>
    <InvOrder>
    <Nr>IIO0000485</Nr>
    <Item>100000036</Item>
    <Qty>20</Qty>
    <Priority>0</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000750</HlOrder>
    </InvOrder>
    <InvOrder>
    <Nr>IIO0000487</Nr>
    <Item>100000045</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000750</HlOrder>
    </InvOrder>
    </Customer>
    <Customer>
    <Seq>10</Seq>
    <Cust>100000148</Cust>
    <Mod>FO</Mod>
    <Tod>DDU</Tod>
    <InvOrder>
    <Nr>IIO0000489</Nr>
    <Item>100000036</Item>
    <Qty>20</Qty>
    <Priority>0</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000751</HlOrder>
    </InvOrder>
    <InvOrder>
    <Nr>IIO0000491</Nr>
    <Item>100000045</Item>
    <Qty>20</Qty>
    <Priority>1</Priority>
    <Reordering>0</Reordering>
    <DelDate>15112005</DelDate>
    <HlOrder>CSO000751</HlOrder>
    </InvOrder>
    </Customer>
    </PickWave>
    </ProdRun>
    </PickData>
    When I registered the XMLSchema, the following types and tables were automatically created and you can see the hierarchy below:
    (by the way, I could not find any xdb_utilities.printNestedTables mentioned elsewhere)
    XML_ORDERS
    |_PickData381_T
    |___ProdRun382_T
    |_____PickWave388_COLL
    |_______PickWave383_T
    |_________Customer387_COLL
    |___________Customer384_T
    |_____________InvOrder386_COLL
    These objects are then used in the following nested tables:
    TABLE_NAME     TABLE_TYPE_NAME     PARENT_TABLE_NAME     PARENT_TABLE_COLUMN
    SYS_NTaK/5zar5S0WitSsgu6OKPQ==     PickWave388_COLL     PickData389_TAB     "XMLDATA"."ProdRun"."PickWave"
    SYS_NTf6QvwVm8SFKz+K/YYWq+WQ==     Item408_COLL     ProdData409_TAB     "XMLDATA"."Item"
    SYS_NTtu05ilrRQqmuEN4k+07VDA==     Customer402_COLL     OutboundParty403_TAB     "XMLDATA"."Customer"
    SYS_NTK6fhWq5uTJ+vKcgBpNm1Fg==     InvOrder386_COLL     SYS_NTIIzv7bkXQSSS43igtfi5eg==     InvOrder
    SYS_NTIIzv7bkXQSSS43igtfi5eg==     Customer387_COLL     SYS_NTaK/5zar5S0WitSsgu6OKPQ==     Customer
    I enabled sql tracing and I got the following TKPROF output
    INSERT INTO IMP_ORDERS (PICK_INVORDERNR, PICK_ITEM, PICK_QTY, PICK_PRIORITY,
    PICK_REORDERING, PICK_HLORDER, PICK_DELDATE, PICK_CUST, PICK_MOD, PICK_TOD,
    PICK_SEQ, PICK_PICKWAVENR, PICK_PICKWAVEPRODLINE, PICK_PICKWAVETOUR,
    PICK_PICKWAVETOURSEQ, PICK_ORDKEY, PICK_RUNKEY) SELECT INVORDERNR, ITEM,
    QTY, PRIORITY, REORDERING, HLORDER, DELDATE, CUST, MOD, TOD, SEQ,
    PICKWAVENR, PICKWAVEPRODLINE, PICKWAVETOUR, PICKWAVETOURSEQ, ROWNUM AS
    PICK_ORDKEY, PRODRUNID FROM (SELECT /*+ cardinality(g 15)*/
    EXTRACTVALUE(VALUE(G), '/InvOrder/Nr') AS INVORDERNR, EXTRACTVALUE(VALUE(G),
    '/InvOrder/Item') AS ITEM, EXTRACTVALUE(VALUE(G), '/InvOrder/Qty') AS QTY,
    EXTRACTVALUE(VALUE(G), '/InvOrder/Priority') AS PRIORITY,
    EXTRACTVALUE(VALUE(G), '/InvOrder/Reordering') AS REORDERING,
    EXTRACTVALUE(VALUE(G), '/InvOrder/HlOrder') AS HLORDER,
    TO_DATE(EXTRACTVALUE(VALUE(G), '/InvOrder/DelDate'),'DDMMYYYY') AS DELDATE,
    F.CUST, F.MOD, F.TOD, F.SEQ, F.PICKWAVENR, F.PICKWAVEPRODLINE,
    F.PICKWAVETOUR, F.PICKWAVETOURSEQ, F.PRODRUNNR, F.PRODRUNDATE,
    F.PRODRUNFINAL, F.PRODRUNID FROM (SELECT /*+ cardinality(e 60)*/VALUE(E) AS
    CUSTOMERNODE, EXTRACTVALUE(VALUE(E), '/Customer/Cust') AS CUST,
    EXTRACTVALUE(VALUE(E), '/Customer/Mod') AS MOD, EXTRACTVALUE(VALUE(E),
    '/Customer/Tod') AS TOD, TO_NUMBER(EXTRACTVALUE(VALUE(E), '/Customer/Seq'))
    AS SEQ, D.PICKWAVENR, D.PICKWAVEPRODLINE, D.PICKWAVETOUR, D.PICKWAVETOURSEQ,
    D.PRODRUNNR, D.PRODRUNDATE, D.PRODRUNFINAL, D.PRODRUNID FROM (SELECT /*+
    cardinality(c 100)*/VALUE(C) AS PICKWAVENODE, EXTRACTVALUE(VALUE(C),
    '/PickWave/Nr') AS PICKWAVENR, TO_NUMBER(EXTRACTVALUE(VALUE(C),
    '/PickWave/ProdLine')) AS PICKWAVEPRODLINE, EXTRACTVALUE(VALUE(C),
    '/PickWave/Tour') AS PICKWAVETOUR, TO_NUMBER(EXTRACTVALUE(VALUE(C),
    '/PickWave/TourSeq')) AS PICKWAVETOURSEQ, A.PRODRUNNR, A.PRODRUNDATE,
    A.PRODRUNFINAL, A.PRODRUNID FROM (SELECT /*+ cardinality(b 1)*/VALUE(B) AS
    PRODRUNNODE, EXTRACTVALUE(VALUE(B), '/ProdRun/Nr') AS PRODRUNNR,
    TO_DATE(EXTRACTVALUE(VALUE(B), '/ProdRun/Date'),'DDMMYYYY') AS PRODRUNDATE,
    EXTRACTVALUE(VALUE(B), '/ProdRun/Final') AS PRODRUNFINAL, X.ID PRODRUNID
    FROM XML_ORDERS X, TABLE(XMLSEQUENCE(EXTRACT(X.XMLFILE,'/PickData/ProdRun'))
    ) B WHERE X.ID = :B1 ) A, TABLE(XMLSEQUENCE(EXTRACT(A.PRODRUNNODE,
    '/ProdRun/PickWave'))) C ) D, TABLE(XMLSEQUENCE(EXTRACT(D.PICKWAVENODE,
    '/PickWave/Customer'))) E ) F, TABLE(XMLSEQUENCE(EXTRACT(F.CUSTOMERNODE,
    '/Customer/InvOrder'))) G ORDER BY PICKWAVEPRODLINE, PICKWAVETOURSEQ,
    PICKWAVENR, SEQ )
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 4324.09 9994.65 0 57193 0 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 4324.09 9994.65 0 57193 0 0
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 68 (recursive depth: 1)
    Rows Row Source Operation
    0 COUNT (cr=0 pr=0 pw=0 time=180 us)
    0 VIEW (cr=0 pr=0 pw=0 time=166 us)
    0 SORT ORDER BY (cr=0 pr=0 pw=0 time=152 us)
    40866 NESTED LOOPS (cr=54973 pr=0 pw=0 time=31065606 us)
    1363 NESTED LOOPS (cr=54937 pr=0 pw=0 time=11037183 us)
    1 NESTED LOOPS (cr=54889 pr=0 pw=0 time=10145883 us)
    1 NESTED LOOPS (cr=54841 pr=0 pw=0 time=9799012 us)
    1 TABLE ACCESS BY INDEX ROWID XML_ORDERS (cr=2 pr=0 pw=0 time=222 us)
    1 INDEX UNIQUE SCAN XML_ORDERS_PK (cr=1 pr=0 pw=0 time=126 us)(object id 58551)
    1 COLLECTION ITERATOR PICKLER FETCH (cr=54839 pr=0 pw=0 time=9798748 us)
    1 COLLECTION ITERATOR PICKLER FETCH (cr=48 pr=0 pw=0 time=346818 us)
    1363 COLLECTION ITERATOR PICKLER FETCH (cr=48 pr=0 pw=0 time=870830 us)
    40866 COLLECTION ITERATOR PICKLER FETCH (cr=36 pr=0 pw=0 time=18739302 us)
    Note that I cancelled this operation before it was over so I imagine that these figures refer to the statistics as of the time when the operation was interrupted.
    So, here are finally my questions.
    In order to create the constraints on the nested tables as shown in other threads, do I need to drop the existing xml_orders table and ancillary object types and recreate them or is there a way to add such constraints using the existing system generated object names?
    Secondly, the xml_orders table may contain severale documents, not just one and his current primary key is the column ID. So, in order to uniquely identify the deepest element in the xml document, I need first to select the relevant document by means of the id column.
    Would it be better to create the indexes containing this id column together with the nested_table_id and array_index?
    Thanks for you help.
    Flavio
    PS: I wrote a 10 lines xsl transformation that I passed on to Saxon together with the 32Mb file. It took less than 1 minute to produce a flat file that was loaded almost instantly by SQL*Loader. So, what I am looking for is a procedure loading this stuff in less than 2 minutes or possibly less.

    Does the following help
    SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:53 2005
    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/GetaxTypes.xsd',
    old   5:                                    bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
    new   5:                                    bfilename(USER,'GetaxTypes.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 => 'private/GetaxTypes.xsd',
    old   5:     schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
    new   5:     schemaDoc => xdbURIType('/home/OTNTEST/xsd/GetaxTypes.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.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:55 2005
    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/PickData.xsd',
    old   5:                                    bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
    new   5:                                    bfilename(USER,'PickData.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 => 'private/PickData.xsd',
    old   5:     schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
    new   5:     schemaDoc => xdbURIType('/home/OTNTEST/xsd/PickData.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.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:58 2005
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    SQL> spool createTable.log
    SQL> --
    SQL> connect &1/&2
    Connected.
    SQL> --
    SQL> CREATE TABLE "XML_ORDERS"
      2     ("ID" NUMBER(7,0) NOT NULL ENABLE,
      3      "XMLFILE" "SYS"."XMLTYPE" ,
      4      "INSERTED" DATE DEFAULT sysdate,
      5       CONSTRAINT "XML_ORDERS_PK" PRIMARY KEY ("ID") USING INDEX ENABLE
      6     ) XMLTYPE COLUMN XMLFILE STORE AS OBJECT RELATIONAL
      7       XMLSCHEMA "private/PickData.xsd"
      8       ELEMENT "PickData"
      9           VARRAY XMLFILE."XMLDATA"."ProdRun"."PickWave" STORE AS TABLE PickWave_TAB
    10             (
    11                ( primary key (nested_table_id, array_index)
    12                ) organization index overflow
    13                VARRAY "Customer" STORE AS TABLE Customer_TAB
    14                  (
    15                    (primary key (nested_table_id, array_index)
    16                    ) organization index overflow
    17                    VARRAY "InvOrder" STORE AS TABLE InvOrder_TAB
    18                      (
    19                        (primary key (nested_table_id, array_index)
    20                        ) organization index overflow
    21                      )
    22                  )
    23            )
    24  /
    Table created.
    SQL> quit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:59 2005
    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 XML_ORDERS (ID, XMLFILE) values (&4, xmltype(bfilename(USER,'&3'),nls_charset_id('AL32UTF8')))
      2  /
    old   1: insert into XML_ORDERS (ID, XMLFILE) values (&4, xmltype(bfilename(USER,'&3'),nls_charset_id('AL32UTF8')))
    new   1: insert into XML_ORDERS (ID, XMLFILE) values (10, xmltype(bfilename(USER,'testcase.xml'),nls_charset_id('AL32UT
    8')))
    1 row created.
    Elapsed: 00:00:00.11
    SQL> commit
      2  /
    Commit complete.
    Elapsed: 00:00:00.01
    SQL> quit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:59 2005
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    SQL> spool testcase.log
    SQL> set trimspool on
    SQL> connect &1/&2
    Connected.
    SQL> --
    SQL> set timing on
    SQL> set long 10000
    SQL> set pages 0 lines 140
    SQL> --
    SQL> -- Testcase code here
    SQL> --
    SQL> set autotrace on explain
    SQL> --
    SQL> create or replace view PROD_RUN_VIEW
      2  (
      3    PRODRUNNODE,
      4    PRODRUNNR,
      5    PRODRUNDATE,
      6    PRODRUNID,
      7    PRODRUNFINAL
      8  )
      9  as
    10  select EXTRACT(XMLFILE,'/PickData/ProdRun'),
    11         EXTRACTVALUE(XMLFILE , '/PickData/ProdRun/Nr'),
    12         TO_DATE(EXTRACTVALUE(XMLFILE, '/PickData/ProdRun/Date'),'DDMMYYYY'),
    13         ID,
    14         EXTRACTVALUE(XMLFILE,'/PickData/ProdRun/Final')
    15    from XML_ORDERS
    16  /
    View created.
    Elapsed: 00:00:00.09
    SQL> create or replace view PICK_WAVE_VIEW
      2  (
      3    PICKWAVENODE,
      4    PICKWAVENR,
      5    PICKWAVEPRODLINE,
      6    PICKWAVETOUR,
      7    PICKWAVETOURSEQ,
      8    PRODRUNNR,
      9    PRODRUNDATE,
    10    PRODRUNID,
    11    PRODRUNFINAL
    12  )
    13  as
    14  select value(PW),
    15         extractValue(value(PW),'/PickWave/Nr'),
    16         TO_NUMBER(EXTRACTVALUE(value(PW),'/PickWave/ProdLine')),
    17         extractValue(value(PW),'/PickWave/Tour'),
    18         TO_NUMBER(extractValue(value(PW),'/PickWave/TourSeq')),
    19         PRODRUNNR,
    20         PRODRUNDATE,
    21         PRODRUNID,
    22         PRODRUNFINAL
    23    FROM PROD_RUN_VIEW, table(xmlsequence(extract(PRODRUNNODE,'/ProdRun/PickWave'))) PW
    24  /
    View created.
    Elapsed: 00:00:00.09
    SQL> create or replace view CUSTOMER_VIEW
      2  (
      3    CUSTOMERNODE,
      4    CUST,
      5    MOD,
      6    TOD,
      7    SEQ,
      8    PICKWAVENR,
      9    PICKWAVEPRODLINE,
    10    PICKWAVETOUR,
    11    PICKWAVETOURSEQ,
    12    PRODRUNNR,
    13    PRODRUNDATE,
    14    PRODRUNFINAL,
    15    PRODRUNID
    16  )
    17  as
    18  select value(CUST),
    19         EXTRACTVALUE(VALUE(CUST), '/Customer/Cust'),
    20         EXTRACTVALUE(VALUE(CUST), '/Customer/Mod'),
    21         EXTRACTVALUE(VALUE(CUST), '/Customer/Tod'),
    22         TO_NUMBER(EXTRACTVALUE(VALUE(CUST), '/Customer/Seq')),
    23         PICKWAVENR,
    24         PICKWAVEPRODLINE,
    25         PICKWAVETOUR,
    26         PICKWAVETOURSEQ,
    27         PRODRUNNR,
    28         PRODRUNDATE,
    29         PRODRUNFINAL,
    30         PRODRUNID
    31    from PICK_WAVE_VIEW, table(xmlsequence(extract(PICKWAVENODE,'/PickWave/Customer'))) CUST
    32  /
    View created.
    Elapsed: 00:00:00.10
    SQL>
    SQL> create or replace view INVOICE_ORDER_VIEW
      2  (
      3    INVORDERNR,
      4    ITEM,
      5    QTY,
      6    PRIORITY,
      7    REORDERING,
      8    HLORDER,
      9    DELDATE,
    10    CUST,
    11    MOD,
    12    TOD,
    13    SEQ,
    14    PICKWAVENR,
    15    PICKWAVEPRODLINE,
    16    PICKWAVETOUR,
    17    PICKWAVETOURSEQ,
    18    PRODRUNNR,
    19    PRODRUNDATE,
    20    PRODRUNFINAL,
    21    PRODRUNID
    22  )
    23  as
    24  SELECT EXTRACTVALUE(VALUE(INV), '/InvOrder/Nr'),
    25         EXTRACTVALUE(VALUE(INV), '/InvOrder/Item'),
    26         EXTRACTVALUE(VALUE(INV), '/InvOrder/Qty'),
    27         EXTRACTVALUE(VALUE(INV), '/InvOrder/Priority'),
    28         EXTRACTVALUE(VALUE(INV), '/InvOrder/Reordering'),
    29         EXTRACTVALUE(VALUE(INV), '/InvOrder/HlOrder'),
    30         TO_DATE(EXTRACTVALUE(VALUE(INV), '/InvOrder/DelDate'),'DDMMYYYY'),
    31         CUST,
    32         MOD,
    33         TOD,
    34         SEQ,
    35         PICKWAVENR,
    36         PICKWAVEPRODLINE,
    37         PICKWAVETOUR,
    38         PICKWAVETOURSEQ,
    39         PRODRUNNR,
    40         PRODRUNDATE,
    41         PRODRUNFINAL,
    42         PRODRUNID
    43   FROM CUSTOMER_VIEW, table(xmlsequence(extract(CUSTOMERNODE,'Customer/InvOrder'))) INV
    44  /
    View created.
    Elapsed: 00:00:00.13
    SQL> select * from INVOICE_ORDER_VIEW
      2  /
    IIO0000461           100000036                    20          1          0 CSO000743            15-NOV-05 100000013
    FO                             DDU                                     6 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000463           100000045                    20          1          0 CSO000743            15-NOV-05 100000013
    FO                             DDU                                     6 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000473           100000036                    20          1          0 CSO000746            15-NOV-05 100000143
    FO                             DDU                                     7 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000475           100000045                    20          1          0 CSO000746            15-NOV-05 100000143
    FO                             DDU                                     7 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000469           100000036                    20          1          0 CSO000745            15-NOV-05 100000140
    FO                             DDU                                     3 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000471           100000045                    20          1          0 CSO000745            15-NOV-05 100000140
    FO                             DDU                                     3 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000489           100000036                    20          0          0 CSO000751            15-NOV-05 100000148
    FO                             DDU                                    10 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000491           100000045                    20          1          0 CSO000751            15-NOV-05 100000148
    FO                             DDU                                    10 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000481           100000036                    20          0          0 CSO000748            15-NOV-05 100000146
    FO                             DDU                                     9 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000483           100000045                    20          1          0 CSO000748            15-NOV-05 100000146
    FO                             DDU                                     9 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000485           100000036                    20          0          0 CSO000750            15-NOV-05 100000147
    FO                             DDU                                     4 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000487           100000045                    20          1          0 CSO000750            15-NOV-05 100000147
    FO                             DDU                                     4 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000457           100000036                    20          1          0 CSO000742            15-NOV-05 100000006
    FO                             DDU                                     5 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000459           100000045                    20          1          0 CSO000742            15-NOV-05 100000006
    FO                             DDU                                     5 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000477           100000036                    20          1          0 CSO000747            15-NOV-05 100000145
    FO                             DDU                                     8 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000479           100000045                    20          1          0 CSO000747            15-NOV-05 100000145
    FO                             DDU                                     8 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000465           100000036                    20          1          0 CSO000744            15-NOV-05 100000114
    FO                             DDU                                     2 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    IIO0000467           100000045                    20          1          0 CSO000744            15-NOV-05 100000114
    FO                             DDU                                     2 IPW0000017                1 00000043_078
                    1
             5 15-NOV-05            1         10
    18 rows selected.
    Elapsed: 00:00:00.22
    Execution Plan
    Plan hash value: 1730223965
    | Id  | Operation                | Name              | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT         |                   |    18 | 10278 |   877   (0)| 00:00:11 |
    |   1 |  NESTED LOOPS            |                   |    18 | 10278 |   877   (0)| 00:00:11 |
    |   2 |   NESTED LOOPS           |                   |    18 |  8424 |   841   (0)| 00:00:11 |
    |   3 |    MERGE JOIN CARTESIAN  |                   |    18 |  4680 |   805   (0)| 00:00:10 |
    |   4 |     TABLE ACCESS FULL    | XML_ORDERS        |     1 |    67 |     3   (0)| 00:00:01 |
    |   5 |     BUFFER SORT          |                   |    18 |  3474 |   802   (0)| 00:00:10 |
    |   6 |      INDEX FAST FULL SCAN| SYS_IOT_TOP_64187 |    18 |  3474 |   802   (0)| 00:00:10 |
    |*  7 |    INDEX UNIQUE SCAN     | SYS_IOT_TOP_64185 |     1 |   208 |     2   (0)| 00:00:01 |
    |*  8 |     INDEX RANGE SCAN     | SYS_C008783       |     1 |       |     0   (0)| 00:00:01 |
    |*  9 |   INDEX UNIQUE SCAN      | SYS_IOT_TOP_64183 |     1 |   103 |     2   (0)| 00:00:01 |
    |* 10 |    INDEX RANGE SCAN      | SYS_C008785       |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       7 - access("NESTED_TABLE_ID"="CUSTOMER_TAB"."SYS_NC0000800009$")
       8 - access("NESTED_TABLE_ID"="CUSTOMER_TAB"."SYS_NC0000800009$")
       9 - access("NESTED_TABLE_ID"="PICKWAVE_TAB"."SYS_NC0000800009$")
           filter("NESTED_TABLE_ID"="XML_ORDERS"."SYS_NC0001000011$")
      10 - access("NESTED_TABLE_ID"="PICKWAVE_TAB"."SYS_NC0000800009$")
    Note
       - dynamic sampling used for this statement
    SQL> quit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    C:\oracle\xdb\otn\347125>You were sequencing the ProdRun node, which is a mistake. Only nodes which occur multiple times should be sequenced...

  • How to create index on XMLType column extension?

    I have an XMLType column named "info" whose corresponding global element has a complexType "InfoType" in namespace "http://example.org/ord". The "InfoType" complexType is extended in two namespaces, "http://example.org/info/zipcode" and "http://example.org/info/street". How do I create a unique index using an "InfoType" element contributed from one of the extension namespaces?
    I have included below a SQL script that completely describes the problem.
    Thanks in advance for your assistance?
    - Ron
    BEGIN
    DBMS_XMLSCHEMA.registerSchema(
    'chapter04prod.xsd',
    '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://example.org/prod"
    targetNamespace="http://example.org/prod"
    elementFormDefault="unqualified">
    <xsd:complexType name="ItemsType">
    <xsd:sequence>
    <xsd:element name="product" type="ProductType"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ProductType">
    <xsd:sequence>
    <xsd:element name="number" type="xsd:integer"/>
    <xsd:element name="name" type="xsd:string"/>
    <xsd:element name="size" type="SizeType"/>
    <xsd:element name="color" type="ColorType"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="SizeType">
    <xsd:simpleContent>
    <xsd:extension base="xsd:integer">
    <xsd:attribute name="system" type="xsd:string"/>
    </xsd:extension>
    </xsd:simpleContent>
    </xsd:complexType>
    <xsd:complexType name="ColorType">
    <xsd:attribute name="value" type="xsd:string"/>
    </xsd:complexType>
    </xsd:schema>',
    TRUE,
    TRUE,
    FALSE,
    FALSE);
    END;
    BEGIN
    DBMS_XMLSCHEMA.registerSchema(
    'chapter04ord1.xsd',
    '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://example.org/ord"
    xmlns="http://example.org/ord"
    xmlns:prod="http://example.org/prod"
    elementFormDefault="qualified">
    <xsd:import namespace="http://example.org/prod"
    schemaLocation="chapter04prod.xsd"/>
    <xsd:simpleType name="OrderNumType">
    <xsd:restriction base="xsd:string"/>
    </xsd:simpleType>
    <xsd:complexType name="InfoType"/>
    <xsd:complexType name="CustomerType">
    <xsd:all>
    <xsd:element name="name" type="CustNameType"/>
    <xsd:element name="number" type="xsd:integer"/>
    <xsd:element name="info" type="InfoType" form="unqualified"/>
    </xsd:all>
    </xsd:complexType>
    <xsd:simpleType name="CustNameType">
    <xsd:restriction base="xsd:string"/>
    </xsd:simpleType>
    <xsd:element name="order" type="OrderType"/>
    <xsd:element name="customer" type="CustomerType"/>
    <xsd:complexType name="OrderType">
    <xsd:sequence>
    <xsd:element name="number" type="OrderNumType"/>
    <xsd:element name="customer" type="CustomerType"
    maxOccurs="unbounded"/>
    <xsd:element name="items" type="prod:ItemsType"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>',
    TRUE,
    TRUE,
    FALSE,
    FALSE);
    END;
    BEGIN
    DBMS_XMLSCHEMA.registerSchema(
    'chapter04infozipcode.xsd',
    '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:ord="http://example.org/ord"
    xmlns="http://example.org/info/zipcode"
    targetNamespace="http://example.org/info/zipcode"
    elementFormDefault="unqualified">
    <xsd:import namespace="http://example.org/ord"
    schemaLocation="chapter04ord1.xsd"/>
    <xsd:complexType name="InfoType">
    <xsd:complexContent>
    <xsd:extension base="ord:InfoType">
    <xsd:sequence>
    <xsd:element name="zipcode" type="xsd:string"/>
    </xsd:sequence>
    </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>
    </xsd:schema>',
    TRUE,
    TRUE,
    FALSE,
    FALSE);
    END;
    BEGIN
    DBMS_XMLSCHEMA.registerSchema(
    'chapter04infostreet.xsd',
    '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:ord="http://example.org/ord"
    xmlns="http://example.org/info/street"
    targetNamespace="http://example.org/info/street"
    elementFormDefault="unqualified">
    <xsd:import namespace="http://example.org/ord"
    schemaLocation="chapter04ord1.xsd"/>
    <xsd:complexType name="InfoType">
    <xsd:complexContent>
    <xsd:extension base="ord:InfoType">
    <xsd:sequence>
    <xsd:element name="street" type="xsd:string"/>
    </xsd:sequence>
    </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>
    </xsd:schema>',
    TRUE,
    TRUE,
    FALSE,
    FALSE);
    END;
    BEGIN
    DBMS_XMLSCHEMA.registerSchema(
    'chapter04nonamespace.xsd',
    '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:ord="http://example.org/ord">
    <xsd:import namespace="http://example.org/ord"
    schemaLocation="chapter04ord1.xsd"/>
    <xsd:element name="info" type="ord:InfoType">
    </xsd:schema>',
    TRUE,
    TRUE,
    FALSE,
    FALSE);
    END;
    CREATE TABLE customer (
    name VARCHAR(64),
    number INTEGER,
    info XMLTYPE)
    XMLType info STORE AS OBJECT RELATIONAL
    XMLSCHEMA "chapter04nonamespace.xsd"
    ELEMENT "info";
    INSERT INTO customer (name, number, info)
    VALUES ('George Jones', 1,
    XMLType(
    '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:street="http://example.org/info/zipcode"
    xsi:type="zipcode:InfoType">
    <zipcode>28877</zipcode>
    </info>');
    INSERT INTO customer (name, number, info)
    VALUES ('Jim Jones', 2,
    XMLType(
    '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:street="http://example.org/info/street"
    xsi:type="street:InfoType">
    <street>3456 Autumn Lane</street>
    </info>');
    SELECT name,
    extractValue(info, '/info/street')
    FROM customer
    WHERE extractValue(info, '/info/street/text()') LIKE '3456%';
    -- How does one create a unique index as follows?
    CREATE UNIQUE INDEX customer_infostreet ON customer (??????);
    -- The following insert should fail with unique index violation!
    INSERT INTO customer (name, number, info)
    VALUES ('Jerry Jones', 3,
    XMLType(
    '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:street="http://example.org/info/street"
    xsi:type="street:InfoType">
    <street>3456 Autumn Lane</street>
    </info>');

    Ron
    Glad you found a solution.. However a more efficient solution is show below
    SQL> connect sys/ as sysdba
    Enter password:
    Connected.
    SQL> set define on
    SQL> --
    SQL> define USERNAME = OTNTEST
    SQL> --
    SQL> def PASSWORD = OTNTEST
    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 OTNTEST cascade
    User dropped.
    SQL> grant connect, resource to &USERNAME identified by &PASSWORD
      2  /
    old   1: grant connect, resource to &USERNAME identified by &PASSWORD
    new   1: grant connect, resource to OTNTEST identified by OTNTEST
    Grant succeeded.
    SQL> grant create any directory, drop any directory to &USERNAME
      2  /
    old   1: grant create any directory, drop any directory to &USERNAME
    new   1: grant create any directory, drop any directory to OTNTEST
    Grant succeeded.
    SQL> grant alter session, create view to &USERNAME
      2  /
    old   1: grant alter session, create view to &USERNAME
    new   1: grant alter session, create view to OTNTEST
    Grant succeeded.
    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 OTNTEST default tablespace USERS temporary tablespace TEMP
    User altered.
    SQL> connect &USERNAME/&PASSWORD
    Connected.
    SQL> --
    SQL> alter session set events ='19027 trace name context forever, level 0x800'
      2  /
    Session altered.
    SQL> BEGIN
      2  DBMS_XMLSCHEMA.registerSchema(
      3  'chapter04prod.xsd',
      4  '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/prod" targetNamespa
    fault="unqualified">
      5     <xsd:complexType name="ItemsType">
      6             <xsd:sequence>
      7                     <xsd:element name="product" type="ProductType"/>
      8             </xsd:sequence>
      9     </xsd:complexType>
    10     <xsd:complexType name="ProductType">
    11             <xsd:sequence>
    12                     <xsd:element name="num" type="xsd:integer"/>
    13                     <xsd:element name="name" type="xsd:string"/>
    14                     <xsd:element name="size" type="SizeType"/>
    15                     <xsd:element name="color" type="ColorType"/>
    16             </xsd:sequence>
    17     </xsd:complexType>
    18     <xsd:complexType name="SizeType">
    19             <xsd:simpleContent>
    20                     <xsd:extension base="xsd:integer">
    21                             <xsd:attribute name="system" type="xsd:string"/>
    22                     </xsd:extension>
    23             </xsd:simpleContent>
    24     </xsd:complexType>
    25     <xsd:complexType name="ColorType">
    26             <xsd:attribute name="value" type="xsd:string"/>
    27     </xsd:complexType>
    28  </xsd:schema>',
    29  TRUE, TRUE, FALSE, FALSE);
    30  END;
    31  /
    PL/SQL procedure successfully completed.
    SQL> BEGIN
      2  DBMS_XMLSCHEMA.registerSchema(
      3  'chapter04ord1.xsd',
      4  '<xsd:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns
    ://example.org/prod" targetNamespace="http://example.org/ord" elementFormDefault="qualified">
      5     <xsd:import namespace="http://example.org/prod" schemaLocation="chapter04prod.xsd"/>
      6     <xsd:simpleType name="OrderNumType">
      7             <xsd:restriction base="xsd:string"/>
      8     </xsd:simpleType>
      9     <xsd:complexType name="InfoType" xdb:SQLType="INFO_TYPE_T"/>
    10     <xsd:complexType name="CustomerType">
    11             <xsd:all>
    12                     <xsd:element name="name" type="CustNameType"/>
    13                     <xsd:element name="num" type="xsd:integer"/>
    14                     <xsd:element name="info" type="InfoType" minOccurs="1" form="unqualified"/>
    15             </xsd:all>
    16     </xsd:complexType>
    17     <xsd:simpleType name="CustNameType">
    18             <xsd:restriction base="xsd:string"/>
    19     </xsd:simpleType>
    20     <xsd:element name="customers" type="CustomersType"/>
    21     <xsd:complexType name="CustomersType">
    22             <xsd:sequence>
    23                     <xsd:element name="customer" type="CustomerType" minOccurs="0" maxOccurs="unbounded"
    24             </xsd:sequence>
    25     </xsd:complexType>
    26     <xsd:element name="order" type="OrderType"/>
    27     <xsd:element name="customer" type="CustomerType"/>
    28     <xsd:complexType name="OrderType">
    29             <xsd:sequence>
    30                     <xsd:element name="num" type="OrderNumType"/>
    31                     <xsd:element name="customer" type="CustomerType" maxOccurs="unbounded"/>
    32                     <xsd:element name="items" type="prod:ItemsType"/>
    33             </xsd:sequence>
    34     </xsd:complexType>
    35  </xsd:schema>',
    36  TRUE, TRUE, FALSE, FALSE);
    37  END;
    38  /
    PL/SQL procedure successfully completed.
    SQL> BEGIN
      2  DBMS_XMLSCHEMA.registerSchema(
      3  'chapter04infozipcode.xsd',
      4  '<xsd:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns
    //example.org/info/zipcode" targetNamespace="http://example.org/info/zipcode" elementFormDefault="unqualifie
      5     <xsd:import namespace="http://example.org/ord" schemaLocation="chapter04ord1.xsd"/>
      6     <xsd:complexType name="InfoType" xdb:SQLType="ZIPCODE_INFO_TYPE_T">
      7             <xsd:complexContent>
      8                     <xsd:extension base="ord:InfoType">
      9                             <xsd:sequence>
    10                                     <xsd:element name="zipcode" type="xsd:string"/>
    11                                     <xsd:element name="suffix" type="xsd:string"/>
    12                             </xsd:sequence>
    13                     </xsd:extension>
    14             </xsd:complexContent>
    15     </xsd:complexType>
    16  </xsd:schema>',
    17  TRUE, TRUE, FALSE, FALSE);
    18  END;
    19  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> BEGIN
      2  DBMS_XMLSCHEMA.registerSchema(
      3  'chapter04infostreet.xsd',
      4  '<xsd:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns
    //example.org/info/street" targetNamespace="http://example.org/info/street" elementFormDefault="unqualified"
      5     <xsd:import namespace="http://example.org/ord" schemaLocation="chapter04ord1.xsd"/>
      6     <xsd:complexType name="InfoType" xdb:SQLType="STREET_INFO_TYPE_T">
      7             <xsd:complexContent>
      8                     <xsd:extension base="ord:InfoType">
      9                             <xsd:sequence>
    10                                     <xsd:element name="street" type="xsd:string"/>
    11                                     <xsd:element name="suffix" type="xsd:string"/>
    12                             </xsd:sequence>
    13                     </xsd:extension>
    14             </xsd:complexContent>
    15     </xsd:complexType>
    16  </xsd:schema>',
    17  TRUE, TRUE, FALSE, FALSE);
    18  END;
    19  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> BEGIN
      2  DBMS_XMLSCHEMA.registerSchema(
      3  'chapter04nonamespace.xsd',
      4  '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ord="http://example.org/ord">
      5     <xsd:import namespace="http://example.org/ord" schemaLocation="chapter04ord1.xsd"/>
      6     <xsd:element name="info" type="ord:InfoType"/>
      7  </xsd:schema>',
      8  TRUE, TRUE, FALSE, FALSE);
      9  END;
    10  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> CREATE TABLE customer (
      2  name VARCHAR(64),
      3  num INTEGER,
      4  info XMLTYPE)
      5  XMLType info STORE AS OBJECT RELATIONAL
      6  XMLSCHEMA "chapter04nonamespace.xsd"
      7  ELEMENT "info";
    Table created.
    SQL>
    SQL> INSERT INTO customer (name, num, info)
      2  VALUES ('George Jones', 1,
      3  XMLType(
      4  '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:zipcode="http://example.org/info/zip
      5     <zipcode>28877</zipcode>
      6     <suffix>s1</suffix>
      7  </info>'));
    1 row created.
    SQL>
    SQL> INSERT INTO customer (name, num, info)
      2  VALUES ('Jim Jones', 2,
      3  XMLType(
      4  '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:street="http://example.org/info/stre
      5     <street>3456 Autumn Lane</street>
      6     <suffix>s2</suffix>
      7  </info>'));
    1 row created.
    SQL> /
    1 row created.
    SQL> SELECT name,
      2         extractValue(info, '/info/zipcode'),
      3         extractValue(info, '/info/street')
      4    FROM customer
      5  WHERE extractValue(info, '/info/zipcode/text()') LIKE '2%'
      6     OR extractValue(info, '/info/street/text()') LIKE '3456%';
    NAME
    EXTRACTVALUE(INFO,'/INFO/ZIPCODE')
    EXTRACTVALUE(INFO,'/INFO/STREET')
    George Jones
    28877
    Jim Jones
    3456 Autumn Lane
    NAME
    EXTRACTVALUE(INFO,'/INFO/ZIPCODE')
    EXTRACTVALUE(INFO,'/INFO/STREET')
    Jim Jones
    3456 Autumn Lane
    SQL>
    SQL> CREATE UNIQUE INDEX customer_infozipcode ON customer(
      2  extractValue
      3  (
      4    info,
      5    '/info[@xsi:type="zipcode:InfoType"]/zipcode',
      6    'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      7    xmlns:zipcode="http://example.org/info/zipcode"'
      8  ))
      9  /
    Index created.
    SQL> select column_name
      2    from user_ind_columns
      3   where INDEX_NAME = 'CUSTOMER_INFOZIPCODE'
      4  /
    COLUMN_NAME
    SYS_NC00014$
    SQL> select INDEX_NAME,COLUMN_EXPRESSION
      2    from user_ind_expressions
      3  /
    INDEX_NAME
    COLUMN_EXPRESSION
    CUSTOMER_INFOZIPCODE
    EXTRACTVALUE(SYS_MAKEXML('0341F05603124922B4F6F94DC5E30C2F',4870,"SYS_NC00004$",
    SQL> DROP INDEX CUSTOMER_INFOZIPCODE
      2  /
    Index dropped.
    SQL> desc INFO_TYPE_T
    INFO_TYPE_T is NOT FINAL
    Name                                      Null?    Type
    SYS_XDBPD$                                         XDB.XDB$RAW_LIST_T
    SQL> --
    SQL> desc ZIPCODE_INFO_TYPE_T
    ZIPCODE_INFO_TYPE_T extends OTNTEST.INFO_TYPE_T
    ZIPCODE_INFO_TYPE_T is NOT FINAL
    Name                                      Null?    Type
    SYS_XDBPD$                                         XDB.XDB$RAW_LIST_T
    zipcode                                            VARCHAR2(4000 CHAR)
    suffix                                             VARCHAR2(4000 CHAR)
    SQL> --
    SQL> desc STREET_INFO_TYPE_T
    STREET_INFO_TYPE_T extends OTNTEST.INFO_TYPE_T
    STREET_INFO_TYPE_T is NOT FINAL
    Name                                      Null?    Type
    SYS_XDBPD$                                         XDB.XDB$RAW_LIST_T
    street                                             VARCHAR2(4000 CHAR)
    suffix                                             VARCHAR2(4000 CHAR)
    SQL> --
    SQL> CREATE UNIQUE INDEX customer_infozipcode ON customer(TREAT(INFO.XMLDATA AS ZIPCODE_INFO_TYPE_T)."zipcod
      2  /
    Index created.
    SQL> select column_name
      2    from user_ind_columns
      3   where INDEX_NAME = 'CUSTOMER_INFOZIPCODE'
      4  /
    COLUMN_NAME
    TREAT("SYS_NC00007$" AS "ZIPCODE_INFO_TYPE_T")."zipcode"
    SQL> select INDEX_NAME,COLUMN_EXPRESSION
      2    from user_ind_expressions
      3  /
    no rows selected
    SQL> INSERT INTO customer (name, num, info)
      2  VALUES ('Jerry Jones', 3,
      3  XMLType(
      4  '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:zipcode="http://example.org/info/zip
      5     <zipcode>28877</zipcode>
      6     <suffix>s1</suffix>
      7  </info>'))
      8  /
    INSERT INTO customer (name, num, info)
    ERROR at line 1:
    ORA-00001: unique constraint (OTNTEST.CUSTOMER_INFOZIPCODE) violated
    SQL> INSERT INTO customer (name, num, info)
      2  VALUES ('Jerry Jones', 3,
      3  XMLType(
      4  '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:street="http://example.org/info/stre
      5     <street>3456 Autumn Lane</street>
      6     <suffix>s3</suffix>
      7  </info>'))
      8  /
    1 row created.
    SQL>In you solution a functional index was created. In my case, by breaking the XML abstraction, and using object-relational SQL to create the index (DDL statements are the one case where I feel this is acceptable) I was able to create a pure B-TREE index which has the same effect..

  • Finder window default size

    Just bought a new imac Retina and still quite new to Mac in general. But everything works fine so far and I find most answers to my newbie questions online somewhere.
    There is one quite annoying thing I could not solve so far:
    My finder window always opens in the same small size. All things I found online to save a new default size did not work.
    I tried closing it and reopen without success. I tried the same with pressing ctrl or alt or cmd or with resizing it while holding ctrl or alt. No change. As soon as I close it and reopen it opens in the unwanted small "default size"
    What else can I try to change this default to the size of my choice ?
    Greetings from Switzerland
    Holger

    Try this - Open a new Finder window, adjust its size and column width, now minimize the window (Apple + 'M'), then click on it from the dock to bring it back, then close it ...and now when you open a new window it should maintain all your recent settings.

  • Need help with creating B*Tree XMLIndex on a structured object-relational xmltype column

    The following is my schema:
    CREATE TABLE TST_AUDIT_TBL
       NOTE                  VARCHAR2(25 CHAR)     null,
       CHANGE_HISTORY        XMLTYPE               not null,
       CHANGE_HISTORY_EXT    XMLTYPE               null
    XMLTYPE COLUMN CHANGE_HISTORY STORE AS OBJECT RELATIONAL XMLSCHEMA "http://www.oracle.com/a.xsd" element "A"
    XMLTYPE COLUMN CHANGE_HISTORY_EXT STORE AS CLOB XMLSCHEMA "http://www.oracle.com/a.xsd" element "AX"
    XML Schema for the above is defined as follows:
    <schema targetNamespace="http://www.oracle.com/a.xsd"
            xmlns:a="http://www.oracle.com/a.xsd"
            xmlns="http://www.w3.org/2001/XMLSchema"  elementFormDefault="qualified">
        <complexType name="AuditExtType">
          <sequence>
            <element name="C" maxOccurs="unbounded" minOccurs="0">
              <complexType>
                <sequence>
                  <element type="string" name="CN"/>
                  <element type="string" name="OV" minOccurs="0" maxOccurs="1"/>
                  <element type="string" name="NV" minOccurs="0" maxOccurs="1"/>
                </sequence>
              </complexType>
            </element>
          </sequence>
        </complexType>
        <complexType name="AuditType">
          <sequence>
            <element type="string" name="M" maxOccurs="1" minOccurs="0"/>
            <element type="string" name="O"/>
            <element name="B" maxOccurs="1" minOccurs="0">
              <complexType>
                <sequence>
                  <element name="BC" minOccurs="1" maxOccurs="unbounded">
                    <complexType>
                      <sequence>
                        <element type="string" name="BN"/>
                        <element name="F" maxOccurs="unbounded" minOccurs="0">
                          <complexType>
                            <sequence>
                              <element type="string" name="FN"/>
                              <element type="string" name="OV" minOccurs="0" maxOccurs="1"/>
                              <element type="string" name="NV" minOccurs="0" maxOccurs="1"/>
                            </sequence>
                          </complexType>
                        </element>
                      </sequence>
                    </complexType> 
                  </element>
                </sequence>
              </complexType>
            </element>
            <element name="T" maxOccurs="1" minOccurs="0">
              <complexType>
                <sequence>
                  <element name="TL" minOccurs="1" maxOccurs="unbounded">
                    <complexType>
                      <sequence>
                        <element type="string" name="TN"/>
                        <element name="C" maxOccurs="unbounded" minOccurs="0">
                          <complexType>
                            <sequence>
                              <element type="string" name="CN"/>
                              <element type="string" name="OV" minOccurs="0" maxOccurs="1"/>
                              <element type="string" name="NV" minOccurs="0" maxOccurs="1"/>
                            </sequence>
                          </complexType>
                        </element>
                      </sequence>
                    </complexType>
                  </element>
                </sequence>
              </complexType>
            </element>
            <element name="I" maxOccurs="1" minOccurs="0">
              <complexType>
                <sequence>
                  <element name="K" maxOccurs="unbounded" minOccurs="0">
                    <complexType>
                      <sequence>
                        <element type="string" name="N"/>
                        <element type="string" name="V"/>
                      </sequence>
                    </complexType>
                  </element>
                </sequence>
              </complexType>
            </element>
          </sequence>
        </complexType>
        <element name="A" type="a:AuditType"/>
        <element name="AX" type="a:AuditExtType"/>
    </schema>
    I want to create a B*Tree XML Index on the above table for the following:
    1. CN
    2. TN
    in the above schema.
    Following the doc, this is what I am issuing:
    SQL> CREATE INDEX audt_audit_idx1 ON TST_AUDIT_TBL(CHANGE_HISTORY) INDEXTYPE IS XDB.XMLINDEX PARAMETERS ('XMLTABLE IXTAB
      2  XMLNAMESPACES(DEFAULT ''http://www.oracle.com/a.xsd''), ''/A'' COLUMNS COLUMN_NAME VARCHAR2(128) PATH ''A/T/TL/C/CN'' ');
    CREATE INDEX audt_audit_idx1 ON TST_AUDIT_TBL(CHANGE_HISTORY) INDEXTYPE IS XDB.XMLINDEX PARAMETERS ('XMLTABLE IXTAB
    ERROR at line 1:
    ORA-29958: fatal error occurred in the execution of ODCIINDEXCREATE routine
    ORA-19276: XPST0005 - XPath step specifies an invalid element/attribute name:
    (A)
    Not sure what is going wrong (and what would be a working xmlindex will look like?)

    Here goes...
    1) Schema registration
    begin
    dbms_xmlschema.registerSchema(
      schemaURL => 'http://www.oracle.com/a.xsd'
    , local     => true
    , genTypes  => true
    , genTables => false
    , enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_NONE
    , schemaDoc =>
    '<schema targetNamespace="http://www.oracle.com/a.xsd"
            xmlns:a="http://www.oracle.com/a.xsd"
            xmlns="http://www.w3.org/2001/XMLSchema"  elementFormDefault="qualified">
        <complexType name="AuditExtType">
          <sequence>
            <element name="C" maxOccurs="unbounded" minOccurs="0">
              <complexType>
                <sequence>
                  <element type="string" name="CN"/>
                  <element type="string" name="OV" minOccurs="0" maxOccurs="1"/>
                  <element type="string" name="NV" minOccurs="0" maxOccurs="1"/>
                </sequence>
              </complexType>
            </element>
          </sequence>
        </complexType>
        <complexType name="AuditType">
          <sequence>
            <element type="string" name="M" maxOccurs="1" minOccurs="0"/>
            <element type="string" name="O"/>
            <element name="B" maxOccurs="1" minOccurs="0">
              <complexType>
                <sequence>
                  <element name="BC" minOccurs="1" maxOccurs="unbounded">
                    <complexType>
                      <sequence>
                        <element type="string" name="BN"/>
                        <element name="F" maxOccurs="unbounded" minOccurs="0">
                          <complexType>
                            <sequence>
                              <element type="string" name="FN"/>
                              <element type="string" name="OV" minOccurs="0" maxOccurs="1"/>
                              <element type="string" name="NV" minOccurs="0" maxOccurs="1"/>
                            </sequence>
                          </complexType>
                        </element>
                      </sequence>
                    </complexType>
                  </element>
                </sequence>
              </complexType>
            </element>
            <element name="T" maxOccurs="1" minOccurs="0">
              <complexType>
                <sequence>
                  <element name="TL" minOccurs="1" maxOccurs="unbounded">
                    <complexType>
                      <sequence>
                        <element type="string" name="TN"/>
                        <element name="C" maxOccurs="unbounded" minOccurs="0">
                          <complexType>
                            <sequence>
                              <element type="string" name="CN"/>
                              <element type="string" name="OV" minOccurs="0" maxOccurs="1"/>
                              <element type="string" name="NV" minOccurs="0" maxOccurs="1"/>
                            </sequence>
                          </complexType>
                        </element>
                      </sequence>
                    </complexType>
                  </element>
                </sequence>
              </complexType>
            </element>
            <element name="I" maxOccurs="1" minOccurs="0">
              <complexType>
                <sequence>
                  <element name="K" maxOccurs="unbounded" minOccurs="0">
                    <complexType>
                      <sequence>
                        <element type="string" name="N"/>
                        <element type="string" name="V"/>
                      </sequence>
                    </complexType>
                  </element>
                </sequence>
              </complexType>
            </element>
          </sequence>
        </complexType>
        <element name="A" type="a:AuditType"/>
        <element name="AX" type="a:AuditExtType"/>
    </schema>'
    end;
    2) Table creation
    CREATE TABLE TST_AUDIT_TBL
       NOTE                  VARCHAR2(25 CHAR)     null,
       CHANGE_HISTORY        XMLTYPE               not null,
       CHANGE_HISTORY_EXT    XMLTYPE               null
    XMLTYPE COLUMN CHANGE_HISTORY STORE AS OBJECT RELATIONAL XMLSCHEMA "http://www.oracle.com/a.xsd" element "A"
    XMLTYPE COLUMN CHANGE_HISTORY_EXT STORE AS CLOB XMLSCHEMA "http://www.oracle.com/a.xsd" element "AX"
    3) Retrieving the nested table and column related to the target element :
    SQL> select dbms_xmlstorage_manage.xpath2TabColMapping(
      2           owner_name => 'DEV'
      3         , table_name => 'TST_AUDIT_TBL'
      4         , column_name => 'CHANGE_HISTORY'
      5         , xpath => '/A/T/TL/C/CN'
      6         , namespaces =>'default ''http://www.oracle.com/a.xsd'''
      7         )
      8  from dual;
    DBMS_XMLSTORAGE_MANAGE.XPATH2T
    <Result>
      <Mapping TableName="SYS_NTr0U7dPWyRu6OVvDN2f5HEg==" ColumnName="CN"/>
    </Result>
    4) Creating the index :
    SQL> create index CHANGE_HISTORY_IX1 on "SYS_NTr0U7dPWyRu6OVvDN2f5HEg==" ("CN");
    Index created
    If you're going to create multiple indexes like this, you could really benefit from renaming all the nested tables to meaningful names. That can be done via DBMS_XMLSTORAGE_MANAGE as well.

  • Inserting XML data into xmltype column

    Oracle version: 10.1.0.5
    OpenVms Alpha V8.3
    1) Tried this and get the error shown below. Removed charset and placed a zero. Same error.
    INSERT INTO xml_demo (xml_data) -- column of xmltype
    VALUES
    xmltype
    bfilename('XML_DIR', 'MOL.XML'),
    nls_charset_id('AL32UTF8')
    ORA-22993: specified input amount is greater than actual source amount
    ORA-06512: at "SYS.DBMS_LOB", line 637
    ORA-06512: at "SYS.XMLTYPE", line 283
    ORA-06512: at line 1
    2) This PL/SQL block works. However maximum raw size around 32K. The file can be around 100K. May be I can load it into a table of raw and somehow concatnate it to insert. Not sure whether this is possible but I am sure there must me a simple way of doing this.
    Subset of the xml file is pasted below.
    set serveroutput on size 1000000
    DECLARE
    file1 bfile;
    v_xml XMLType;
    len1 number(6);
    v_rec1 raw(32000);
    BEGIN
    file1 := bfilename('XML_DIR','MOL.XML');
    DBMS_LOB.fileopen(file1, DBMS_LOB.file_readonly);
    len1 := DBMS_LOB.getLength(file1);
    v_rec1 := dbms_lob.substr(file1,len1,1);
    v_xml := xmltype(UTL_RAW.CAST_TO_VARCHAR2(v_rec1));
    INSERT INTO xml_demo (xml_data) VALUES (v_xml);
    COMMIT;
    DBMS_LOB.fileclose(file1);
    exception
    when others then
    dbms_output.put_LINE (sqlerrm);
    DBMS_LOB.fileclose(file1);
    END;
    <?xml version="1.0" encoding="UTF-8"?>
    <MolDocument DtdVersion="3" DtdRelease="0">
    <DocumentIdentification v="MOL_20100331_1500_1600"/>
    <DocumentVersion v="1"/>
    <DocumentType v="A43"/>
    <SenderIdentification codingScheme="A01" v="17X100Z100Z0001H"/>
    <SenderRole v="A35"/>
    <ReceiverIdentification codingScheme="A01" v="10XFR-RTE------Q"/>
    <ReceiverRole v="A04"/>
    <CreationDateTime v="2010-03-31T14:10:00Z"/>
    <ValidTimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <Domain codingScheme="A01" v="10YDOM-1001A001A"/>
    <MolTimeSeries>
    <ContractIdentification v="RTE_20100331_1500_16"/>
    <ResourceProvider codingScheme="A01" v="10XFR-RTE------Q"/>
    <AcquiringArea codingScheme="A01" v="17Y100Z100Z00013"/>
    <ConnectingArea codingScheme="A01" v="10YFR-RTE------C"/>
    <AuctionIdentification v="AUCTION_20100331_1500_1600"/>
    <BusinessType v="A10"/>
    <BidTimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <MeasureUnitQuantity v="MAW"/>
    <Currency v="EUR"/>
    <MeasureUnitPrice v="MWH"/>
    <Direction v="A02"/>
    <MinimumActivationQuantity v="50"/>
    <Status v="A06"/>
    <Period>
    <TimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <Resolution v="PT60M"/>
    <Interval>
    <Pos v="1"/>
    <Qty v="50"/>
    <EnergyPrice v="50.45"/>
    </Interval>
    </Period>
    </MolTimeSeries>
    </MolDocument>

    Marc
    Thanks. I understand what you are saying. I have been copying files in binary mode from NT servers into VMS. I have to get a proper xml file via FTP from the originating system to further investigate.
    I have one last item i need help on. If anything looks obvious let me know:
    +1) The xsd defintion of Qty (type: QuantityType) and EnergyPrice (type: Amount Type)+
                   <xsd:element name="Qty" type="ecc:QuantityType">
                        <xsd:annotation>
                             <xsd:documentation/>
                        </xsd:annotation>
                   </xsd:element>
                   <xsd:element name="EnergyPrice" type="ecc:AmountType" minOccurs="0">
                        <xsd:annotation>
                             <xsd:documentation/>
                        </xsd:annotation>
                   </xsd:element>
    +2) Definition of AmountType and QuantityType in the parent xsd+
         <xsd:complexType name="AmountType">
              <xsd:annotation>
                   <xsd:documentation>
                        <Uid>ET0022</Uid>
                        <Definition>The monetary value of an object</Definition>
                   </xsd:documentation>
              </xsd:annotation>
              <xsd:attribute name="v" use="required">
                   <xsd:simpleType>
                        <xsd:restriction base="xsd:decimal">
                             <xsd:totalDigits value="17"/>
                        </xsd:restriction>
                   </xsd:simpleType>
              </xsd:attribute>
         </xsd:complexType>
         <!--_________________________________________________-->
         <xsd:complexType name="QuantityType">
              <xsd:annotation>
                   <xsd:documentation>
                        <Uid>ET0012</Uid>
                        <Definition>(Synonym "qty") The quantity of an energy product. Positive quantities shall not have a sign.</Definition>
                   </xsd:documentation>
              </xsd:annotation>
              <xsd:attribute name="v" type="xsd:decimal" use="required"/>
         </xsd:complexType>
         <!--________________
    +3. Data in the XML file+
    <Period>
    <TimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <Resolution v="PT60M"/>
    <Interval>
    <Pos v="1"/>
    <Qty v="50"/>
    <EnergyPrice v="50.45"/>
    </Interval>
    +4) When I do the load:+
    the EnergyPrice is saved in the xmltype column as <EnergyPrice v="50"/>
    Losing its decimal value of .45
    +5) When I select as follows:+
    **DEV** SQL>> l
    1 SELECT
    2 EXTRACTVALUE(x2.column_value,'/MolTimeSeries/Period/Interval/EnergyPrice/@v') v1,
    3 EXTRACTVALUE(x2.column_value,'/MolTimeSeries/Period/Interval/EnergyPrice') v2,
    4 EXTRACTVALUE(x2.column_value,'/MolTimeSeries/Period/Interval/Qty') v3
    5 FROM balit_mol_xml x,
    6 TABLE(
    7 XMLSEQUENCE(
    8 EXTRACT(x.xml_payload, '/MolDocument/MolTimeSeries')
    9 )
    10 ) x2
    11* WHERE EXISTSNODE(x.xml_payload,'/MolDocument/DocumentIdentification[@v="MOL_20100331_1500_1600"]') = 1
    +6) get the result+
    50
    AmountType479_T(XDB$RAW_LIST_T('1301000000'), 50)
    QuantityType471_T(XDB$RAW_LIST_T('1301000000'), 50)
    +7) XDB$RAW_LIST_T('1301000000'),+
    Does that tell what I am doing wrong?

  • How to create index on xmltype column

    I have a table having only one column xmlcontent (xmltype). This table stores xml data of about 10GB size. I'm using extract value to move the data to staging tables.
    How can I create index on xmltype column?
    Create index indexname on table (column) doesn't seem to work.
    Sample xmlstructure is given below
    <Root>
    <Type>Insert</Type>
    <Date>2006-12-29</Date>
    <Source>8</Source>
    <id>data</id>
    <key_flds>
    <fld><id>Key1</id><val>C</val></fld>
    <fld><id>Key2</id><val>429672</val></fld>
    <fld><id>Key3</id><val>8</val></fld>
    </key_flds>
    </Root>
    I need to do extract value on all tags and move them to corresponding relational tables.

    Hi, you need to create them using something like this (what I have used and work rather well - if I did not load the xml into an xml table, the processing took about 10 minutes, while the indexed xml table took just a few seconds). statute_xml is the table name and sxmldoc is the xml column/field.
    create index desc_idx on statute_xml
    (sxmldoc.existsNode('/SimpleTypeCompanion/EnumerationValue/@description'))
    create index sid_idx on statute_xml
    (sxmldoc.existsNode
    ('/SimpleTypeCompanion/EnumerationValue/Text')
    create index effdate_idx on statute_xml
    (sxmldoc.existsNode
    ('/SimpleTypeCompanion/EnumerationValue/@effectiveDate')
    Hope this helps.
    Ben

  • XMLType column selection

    I have the following in an XMLType column:
    <ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040" />
    <templateId root="2.16.840.1.113883.10.20.1" />
    <id root="2.16.840.1.113883.3.140.1.0.6.1" extension="7380300531250060" />
    <code code="34133-9" displayName="Summarization of episode note" codeSystem="2.16.840.1.113883.6.1" />
    <title>Madison Medical Center P. A. Continuity of Care Document</title>
    <effectiveTime value="20090508115140-0400" />
    <confidentialityCode code="N" displayName="Normal" codeSystem="2.16.840.1.113883.5.25" />
    <languageCode code="en-US" />
    <recordTarget>
    <patientRole>
    <id root="2.16.840.1.113883.3.140.1.0.6.4" extension="10" />
    <id root="2.16.840.1.113883.4.1" extension="345003434" />
    <addr>
    <streetAddressLine>3456 West Palm</streetAddressLine>
    <streetAddressLine>Apt. #34</streetAddressLine>
    <city>Madison</city>
    <state>CA</state>
    <postalCode>95653</postalCode>
    </addr>
    <telecom use="HP" value="tel:(916) 555-3293" />
    <telecom value="mailto:[email protected]" />
    <patient>
    <name>
    <given>FirstName</given>
    <given>W</given>
    <family>LastName</family>
    </name>
    <administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1" codeSystemName="AdministrativeGender" />
    <birthTime value="19380816" />
    <maritalStatusCode code="M" displayName="Married" codeSystem="2.16.840.1.113883.11.12212" codeSystemName="MaritalStatus" />
    <raceCode code="2106-3" displayName="White" codeSystem="2.16.840.1.113883.11.14914" codeSystemName="Race" />
    </patient>
    </ClinicalDocument>
    When I run select extractvalue(CCD_DOC, 'recordTarget/patientRole/patient/name/family') from CCD; no errors are returned but I also don't get the value. What am I missing?

    In a word - namespace definitions...
    Here's an example written using XMLQuery, rather than extractValue, which is the preferred approach in 10.2.x and later...
    SQL> with CCD as
      2  (
      3  select XMLTYPE(
      4  '<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      5     <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/>
      6     <templateId root="2.16.840.1.113883.10.20.1"/>
      7     <id root="2.16.840.1.113883.3.140.1.0.6.1" extension="7380300531250060"/>
      8     <code code="34133-9" displayName="Summarization of episode note" codeSystem="2.16.840.1.113883.6.1"/>
      9     <title>Madison Medical Center P. A. Continuity of Care Document</title>
    10     <effectiveTime value="20090508115140-0400"/>
    11     <confidentialityCode code="N" displayName="Normal" codeSystem="2.16.840.1.113883.5.25"/>
    12     <languageCode code="en-US"/>
    13     <recordTarget>
    14             <patientRole>
    15                     <id root="2.16.840.1.113883.3.140.1.0.6.4" extension="10"/>
    16                     <id root="2.16.840.1.113883.4.1" extension="345003434"/>
    17                     <addr>
    18                             <streetAddressLine>3456 West Palm</streetAddressLine>
    19                             <streetAddressLine>Apt. #34</streetAddressLine>
    20                             <city>Madison</city>
    21                             <state>CA</state>
    22                             <postalCode>95653</postalCode>
    23                     </addr>
    24                     <telecom use="HP" value="tel:(916) 555-3293"/>
    25                     <telecom value="mailto:[email protected]"/>
    26                     <patient>
    27                             <name>
    28                                     <given>FirstName</given>
    29                                     <given>W</given>
    30                                     <family>LastName</family>
    31                             </name>
    32                             <administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1" codeSystemName="AdministrativeGender"/>
    33                             <birthTime value="19380816"/>
    34                             <maritalStatusCode code="M" displayName="Married" codeSystem="2.16.840.1.113883.11.12212" codeSystemName="MaritalStatus"/>
    35                             <raceCode code="2106-3" displayName="White" codeSystem="2.16.840.1.113883.11.14914" codeSystemName="Race"/>
    36                     </patient>
    37             </patientRole>
    38     </recordTarget>
    39  </ClinicalDocument>') as CCD_DOC from dual
    40  )
    41  select XMLCAST
    42         (
    43           XMLQUERY
    44           (
    45              'declare default element namespace  "urn:hl7-org:v3"; (: :)
    46               declare namespace voc = "urn:hl7-org:v3/voc"; (: :)
    47               $doc/ClinicalDocument/recordTarget/patientRole/patient/name/family'
    48               passing CCD_DOC as "doc"
    49               returning content
    50           )
    51           as VARCHAR2(4000)
    52         )
    53    from CCD
    54  /
    XMLCAST(XMLQUERY('DECLAREDEFAULTELEMENTNAMESPACE"URN:HL7-ORG:V3";(::)DECLARENAME
    LastName
    SQL>

  • Impdp, XMLType column and ora-26093

    Hello!
    I have some problem with importing XMLType columns with data longer than 2000 symbols.
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    test data:
    create table some_tab (id varchar2(10), xml XMLType);
    insert into some_tab values('short', XMLType('<foo></foo>'));
    -- we use clob to pass more than 2000 symbols
    declare
    c clob := '<x> || lpad('</x>', 2700, 'a');
    begin
    insert into some_tab values('long', XMLType(c));
    end;
    then I export data with expdp...
    and if I import dump into other schema on the same server - that's ok,
    BUT if I import data into schema on other server - I have this error:
    KUP-11007: conversion error loading table ......
    ORA-26093: input data column size (2707) exceeds the maximum input size (2000)
    KUP-11009: data for row: ....
    what I'm doing wrong?
    thank you

    user2606534 wrote:
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    ORA-26093: input data column size (2707) exceeds the maximum input size (2000)
    Bug 7209038
    DATAPUMP NOT IMPORTING XMLTYPE OBJECTS. ORA-26093
    Currently no workaround is available for this, although 11gR2 should have it fixed.

Maybe you are looking for