Query in XMLType

I have stored a typical Purchase Order List as XMLType in
Oracle. The structure looks roughly as -
<polist>
<po>
<customer>
<lineitems>
<lineitem>
<item>
<price>
<quantity>
So my polist has multipe po's and each po's has multipe items.
Now, I want to perform following xpath query -
- /polist/po/lineitems/lineitem/item[price="$100"]
In other words, find me an "item with specific price" from list
of all the items in all the po's in my polist.
From what I understand, predicates are not support by XPATH in
Oracle. How can I achieve this using SQL & Extract/exist ?
Any thoughts ??
--Naren

Steve:
Thanks for your response. Your solution works !! BTW, your book
has been very handy in my work.
Now, I am taking the same PO and trying to store it into
seperate tables. My document structure is similar to Example 12-
20 in your book (Oracle XML Applications) - department with
several employees. In my case, I have a purchase order with
several lineitems.
Essentially, I followed the example and got the code (written by
you) from Oreilly website to make it work with my example. Now
the problem is when I use putXML to save, the first level gets
saved with no problem.
So, as shown in the snippet below -
>>>>
<?xml version="1.0" encoding='UTF-8'?>
<ROWSET>
<ROW>
<PO_ID>10</PO_ID>
<LINEITEMS>
<LINEITEM>
<ID>7782</ID>
<PRICE>100</PRICE>
<TAXRATE>24</TAXRATE>
<QUANTITY>20</QUANTITY>
<DISCOUNT>10</DISCOUNT>
</LINEITEM>
>>>>
If I don't include the "LINEITEM" data, the instead of trigger
fires properly and the PO_ID makes it to the po_table when I
use "putXML" utility.
BTW, I modeled everything like example 12-20 - po_table,
lineitem_table, lineitem_type, lineitem_list, instead of
trigger, po_view, etc...
Now, when I try to use the "putXML" to insert data at both
levels - po and lineitem as shown in above snippet of input xml
doc, I get the following exception -
java OracleXML putXML -user "scott/tiger" -fileName bar.xml po_view
oracle.xml.sql.OracleXMLSQLException: 'java.sql.SQLException:
Non supported character set: oracle-ch
aracter-set-178' encountered during processing ROW element 0.
All prior XML row changes were rolled
back. in the XML document.
at oracle.xml.sql.dml.OracleXMLSave.saveXML
(OracleXMLSave.java:2298)
at oracle.xml.sql.dml.OracleXMLSave.saveXML
(OracleXMLSave.java:2175)
at oracle.xml.sql.dml.OracleXMLSave.insertXML
(OracleXMLSave.java:1264)
at OracleXML.Put_XML(OracleXML.java:467)
at OracleXML.ExecutePutXML(OracleXML.java:389)
at OracleXML.main(OracleXML.java:177)
I tried several variation by changing the encoding in my XML
document to - UTF-8, Unicode, etc..
I am using Oracle 9i (9.0.1.1) on windows 2000.
If you need additional information, please let me know !!
--Naren

Similar Messages

  • Query on XMLType! URGENT!!!

    Please, what the most efficient way to query a xmltype column?
    My xml's are 250KB ~ 1.5 MB and my table have over 130.000 records.
    I have tried:
    1) interMedia -> create index [indexname] on [table] (field) indextype is ctxsys.context parameters ('section group path_section_group')
    but results a error on creating...
    2) Table Functions, but a enough memory error results...
    3) create index on xpath directly, but the repetead tag's are discarded...
    I don't know what to do...
    Please, help me!!!
    Thanks...
    Marlon

    May be this is of some help -
    "compile error in hidden module: clBExevent bulider" error in BW 3.5!

  • Query about XMLTYPE column structured storage in Oracle Xml db

    Dear All,
    DB Version: Oracle 11g (11.2.0.3.0)
    I have an table having one column as XMLTYPE with Structured storage.
    CREATE TABLE Orders
        Order_id NUMBER NOT NULL,
        Order_etc VARCHAR2(100),
        Order_desc XMLType NOT NULL
        XMLTYPE Order_desc STORE AS OBJECT RELATIONAL XMLSCHEMA  "http://localhost/public/xsd/order_desc_xsd.xsd" ELEMENT "OrderState";
    I have then registered the XSD with XML Db schema which is required for Structured storage.
    Before this table creation I had created a table (db_objects) of XMLTYPE and was able to use the below query to check for what all objects the XMLTYPE table got broken into when I registered its XSD.
        SELECT column_name,     
               data_type
        FROM   user_tab_cols
        WHERE  table_name = 'DB_OBJECTS';
    And used below query to look for data stored in Object-Relational structure for my table (DB_OBJECTS) created with XMLTYPE definition.
      SELECT EXTRACTVALUE(xseq.column_value, '/THISROW/OWNER')       AS owner
        ,      EXTRACTVALUE(xseq.column_value, '/THISROW/OBJECT_NAME') AS object_name
        ,      EXTRACTVALUE(xseq.column_value, '/THISROW/OBJECT_TYPE') AS object_type
        ,      EXTRACTVALUE(xseq.column_value, '/THISROW/OBJECT_ID')   AS object_id
        ,      EXTRACTVALUE(xseq.column_value, '/THISROW/CREATED')     AS created
        FROM   db_objects do
         ,      TABLE(XMLSEQUENCE(EXTRACT(VALUE(do), '/ROWSET/THISROW'))) xseq 
        WHERE  ROWNUM <= 10;
    Now could someone let me know, how to find how the column (Order_desc) of XMLTYPE was broken down into further objects just like I did for the Table with XMLTYPE (as shown above)?
    Many Thanks.

    First given that you are on 11.2, ExtractValue is deprecated and the documentation lists three options to use instead.  Here is one option (untested)
    SELECT owner, object_name, object_type, object_id, created
      FROM db_objects do,
           XMLTable('/ROWSET/THISROW'
                    PASSING do.object_value
                    COLUMNS
                    -- Set data types accordingly
                    owner        VARCHAR2(20) PATH 'owner',
                    object_name  VARCHAR2(20) PATH 'object_name',
                    object_type  VARCHAR2(20) PATH 'object_type',
                    object_id    VARCHAR2(20) PATH 'object_id',
                    created      VARCHAR2(20) PATH 'created');
    Second, why does column order matter?  You are storing in an object relational method.  As long as the XML is valid per the schema, the Oracle will be able to store the data and later retrieve it as well.  How that data is stored is mostly Oracle internals and should not be touched as it can be changed from version to version.  You can use schema annotation to control how Oracle maps and stores the XML, but nothing in there specifies column order that I am aware of.
    It seems additional details are missing as to what you need the information for so that would help others answer your question.

  • Problem query of XMLType column in XSQL servlet

    Hi all,
    I'm having trouble debugging the following error from a query on an XMLType column in an XSQL page query:
    <page xmlns:xsql="urn:oracle-xsql" connection="jdbc/DBConnection1DS">
    <xsql:query max-rows="1" null-indicator="no">
    SELECT extractValue(x.DOCBOOKS_DOC, '/book/part/title', 'xmlns="http://docbook.org/ns/docbook"') "BOOK TITLE"
    FROM DOCBOOKS_STORE x
    </xsql:query>
    </page>
    which returns the following error message:
    <page>
    <ERROR>
    oracle.xml.sql.OracleXMLSQLException: Character ' ' is not allowed in an XML tag name.
    </ERROR>
    </page>
    The SQL query works fine in the SQL Worksheet and SQL Plus, only when I stick it in an XSQL query. I've tested the XSQL Page environment with a query on Number Datatype column and no issues there either.
    Any suggestions, much appreciated. Thanks.
    George

    The XML SQL Utility creates XML tags named after your column aliases.
    You have aliased the column to a name containing a space: "BOOK TITLE"
    This error is telling you that the implied XML element whose name matches this column alias, which would be <BOOK TITLE> is not a legal name for an XML element since it has a space in it.
    You'll need to pick a column alias with no space in the name. For example, "BOOK_TITLE" and then in your XSLT stylesheet (or whatever downstream formatting tool you may be using) remove the underscore from the name and replace it with a space.

  • Query using xmltype not working

    I have a table rad_reports that has an xmltype column, report_txt. This query shows that I have a document in the db:
    select r.report_txt.extract('/REPORT/IMPRESSION').getStringVal() from rad_reports r
    where accession=12;
    and it shows:
    <IMPRESSION>
    this is a test
    </IMPRESSION>
    But the following query results in "no rows selected":
    select r.report_txt.getclobval()
    from rad_reports r
    where contains(report_txt, 'test INPATH(/REPORT/IMPRESSION)')>0;
    Furthermore, this query also returns no results:
    select count(*) from rad_reports r
    WHERE CONTAINS(report_txt,'HASPATH(/REPORT/IMPRESSION)') > 0;
    What's going wrong?

    Please post the index creation script.

  • Update query for XMLTYPE column

    Hello everyone,
    I have inserted xml data into XMLTYPE column of my table,xml data is something like this
    <Data type="FYI">                         
    <ID xmlns="http://orcl.com">T-1-1</ID>
    <Category>FRAME</Category>
    <ProductID>1</ProductID>
    <Name xmlns="http://orcl.com">Frame </Name>
    <Type>BASIC</Type>
    <Code>INSTALL</Code>
    <NodeID>1</NodeID>
    </Data>
    Now i need to update the values inside the <Data> element,like
    ID == T-2-2
    Category == IFRAME
    ProductID == 1.1
    Name == IFRAME
    We are using oracle 10g R2.
    Please help me out how to update. It would be very thankfull for your valuble suggestions
    Thanks in advance

    <Services>
    <DataService type="FRLY">
    <ID xmlns="http://www.openapplications.org/oagis/9">T-1-1-FRLY</ID>
    <CategoryCode>FRAME</CategoryCode>
    <ProductOfferingID>1</ProductOfferingID>
    <Name xmlns="http://www.openapplications.org/oagis/9">Frame Relay</Name>
    <SubType>FRLY - BASIC</SubType>
    <ActionCode>INSTALL</ActionCode>
    <NodeID>1</NodeID>
    <Contract>
    <ID xmlns="http://www.openapplications.org/oagis/9" schemeName="Networx Universal">00000</ID>
    <Category name="Contract Type">U</Category>
    </Contract>
    <Contract>
    <Type xmlns="http://www.openapplications.org/oagis/9">Routine</Type>
    </Contract>
    <CustomerParty>
    <Location/>
    </CustomerParty>
    <ProvisioningStatus type="BillingSetup">
    <Description xmlns="http://www.openapplications.org/oagis/9">C</Description>
    </ProvisioningStatus>
    <MileStone>
    <ID xmlns="http://www.openapplications.org/oagis/9">CWD</ID>
    <Date>2007-01-29</Date>
    </MileStone>
    <ActivityStatus>
    <Code xmlns="http://www.openapplications.org/oagis/9" name="DueDate"/>
    <EffectiveDateTime xmlns="http://www.openapplications.org/oagis/9">2007-01-29T00:00:00Z</EffectiveDateTime>
    </ActivityStatus>
    <AssociatedIDs>
    <ID xmlns="http://www.openapplications.org/oagis/9">1</ID>
    </AssociatedIDs>
    <AssociatedIDs>
    <TemporaryID schemeName="OPKEY">34908</TemporaryID>
    </AssociatedIDs>
    <Location>
    <ID xmlns="http://www.openapplications.org/oagis/9">T-510092</ID>
    </Location>
    <OrderID>RequestID</OrderID>
    <Accessory>
    <ActionCode>ADD</ActionCode>
    <Description xmlns="http://www.openapplications.org/oagis/9">IBM ESERVER-XSERIES306</Description>
    <CategoryCode>5</CategoryCode>
    <InstallVendorParty>
    <Name xmlns="http://www.openapplications.org/oagis/9">MCI</Name>
    </InstallVendorParty>
    </Accessory>
    <Circuit>
    <ID xmlns="http://www.openapplications.org/oagis/9">T-1-1-FRLY</ID>
    <AssociatedIDs/>
    </Circuit>
    </DataService>
    </Services>
    This was my xml which i have inserted into DB for the column XMLTYPE.Now i need to update few values in this whole file like values of
    ID under<DataService>
    Name under <DataService>
    ID under <Contract>
    Description under <ProvisioningStatus>
    i was using the UPDATEXML query to update those it's saying i row updated but when i extract it says null.
    Please help me out to solve this problem.
    Thanks in advance.

  • XPath query against XMLType

    Hello,
    I am trying to reproduce the following XPath query using XDB functionality against a XMLType column:
    //AtomicPart[@MyID='190' or @MyID='495' or @MyID='1662']
    If I do the following I do get all AtomicParts:
    select X.xml.extract('//AtomicPart') FROM TEST X
    But I havent figured out how to do the or operation. Is it possible or does it require views?
    Thank you,
    Robert

    Robert
    Need to see the instance document in order to answer this..

  • Simple query on xmltype not working

    I have a table rad_reports that has an xmltype column, report_txt. This query shows that I have a document in the db:
    select r.report_txt.extract('/REPORT/IMPRESSION').getStringVal() from rad_reports r
    where accession=12;
    and it shows:
    <IMPRESSION>
    this is a test
    </IMPRESSION>
    But the following query results in "no rows selected":
    select r.report_txt.getclobval()
    from rad_reports r
    where contains(report_txt, 'test INPATH(/REPORT/IMPRESSION)')>0;
    What's going wrong?

    Wrong forum.. queries using contains should be posted in the oracle text forum..

  • XMLDB query on XmlType Column.

    Hi,
    I’ve some problems.
    I’ve some search queries which are working on normal relation table, but I don’t know how it works on XMLDB(Oracle 10gR2)
    Structure of XML file
    My xml table structure will be :
    Create table <tablename>
    Person_Id number primary key,
    Person_BankName varchar2,
    DateOfEntry date,
    Xmlcol xmltype
    Xmlcol xmltype will be mapped to a schema for the below xml file.
    XML File
    <Person>
         <Information>
              <firstname>Suchendra</firstname>
              <lastname>Kumar</lastname>
              <middlename>Krishna</middlename>
         </Information>
         <Account>
              <accountno>12212</accountno>
              <balance>42323.89</balance>
              <opendate>12-03-2005</opendate>
         </Account>
         <Transaction>
              <transamount>1000</transamount>
              <balance>41323.89</balance>
              <trandate>14-03-2005</ trandate >
              <trantime>10:40:22</trantime>
         </ Transaction >
    </Person>
    SQL Queries Required
    1.     Query to fetch the records whose transaction has been done from date 12-03-2001 to date 01-01-2005.
    2.     Query to fetch the records whose lastname= “*Kumar”
    3.     Query to fetch the records whose transaction has been done from time 9:09:55 to time12:26:23.
    4.     Query to fetch the records whose balance > 4000 and balance < 5000.
    5.     Regular expression Search in XMLDB. Ex: searching for records whose firstname has ‘su*’ or ‘*ab’ in it.
    Can anyone help me in this..
    Thanks
    Athar

    1. select *
    from <tablename>
    where extractValue(Xmlcol, '/Person/trandate') is between '12-03-2001' and '01-01-2005';
    2. select *
    from <tablename>
    where extractValue(Xmlcol, '/Person/lastname') like '*Kumar';
    3. select *
    from <tablename>
    where extractValue(Xmlcol, '/Person/trantime') is between '9:09:55' and '12:26:23';
    4. select *
    from <tablename>
    where extractValue(Xmlcol, '/Person/balance') > 4000'
    and extractValue(Xmlcol, '/Person/balance') < 5000;
    5. select *
    from <tablename>
    where extractValue(Xmlcol, '/Person/firstname') like 'su*'
    or extractValue(Xmlcol, '/Person/firstname') like ‘*ab’;
    Regards,
    Kamal Shrivastava

  • Query on XMLType

    Folks:
    Can I perform queries below on XMLType -
    1. /polist/po/lineitems/lineitem/item[price="$300"]
    2. /polist/po[lineitems/lineitem/item[taxrate="3%"]]
    3. //item
    Where I the "xml file" has list of traditional po's.
    --naren

    Yes.
    With the 9.0.1.1 maintenance release of Oracle9i (I've tried it
    on Windows NT) you have the full capability of XPath available
    to you in the extract() and existsNode() methods
    on XML Type.
    Make sure that if you query for "$300" that you really have the
    string "$300" and not the number 300, otherwise, you should use
    the predicate xxx = 300 instead of xxx = "$300"

  • Why Is Query Against XMLTYPE Table ACME_CUST Doing A Full Table Scan?

    On our Oracle Database 11g Enterprise Edition Release 11.2.0.1.0, we have a query against against a 25,214 record XMLTYPE ACME_CUST table.
    SELECT rownum   AS seq,
          EID  AS eid,
          SUBSTR(CUST_ID, 1, INSTR(CUST_ID, '|')-1) AS tgt_acme_customer_id,
          SUBSTR(CUST_ID, INSTR(CUST_ID, '|')   +1) AS src_acme_customer_id_list
        FROM
          (SELECT ac.eid EID,
            listagg(ac.acme_cust_id, '|') WITHIN GROUP (
          ORDER BY ac.acme_cust_id, ac.acme_cust_id) CUST_ID
          FROM ACME_CUST ac
          GROUP BY ac.eid
          HAVING COUNT(ac.acme_cust_id)>1)Explain plan shows:
    Select Statement
    Count
    VIEW
    FILTER
    Filter Predicates
    COUNT(*) > 1
    SORT GROUP BY
    TABLE ACCESS ACME_CUST FULL
    The ACME_CUST Table has a virtual column defined on acme_cust_id along with a corresponding index. This filed is also defined as a primary key.
    Here is the table definitiion and associated statements:
    CREATE
      TABLE "N98991"."ACME_CUST" OF XMLTYPE
        CONSTRAINT "ACME_CUST_ID_PK" PRIMARY KEY ("ACME_CUST_ID") USING INDEX
        PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536
        NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1
        FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE
        DEFAULT) TABLESPACE "ACME_DEV" ENABLE
      XMLTYPE STORE AS SECUREFILE BINARY XML
        TABLESPACE "ACME_DEV" ENABLE STORAGE IN ROW CHUNK 8192 CACHE READS LOGGING
        NOCOMPRESS KEEP_DUPLICATES STORAGE(INITIAL 106496 NEXT 1048576 MINEXTENTS 1
        MAXEXTENTS 2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT)
      ALLOW NONSCHEMA ALLOW ANYSCHEMA VIRTUAL COLUMNS
        "EID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)                              
    /customerProfile/@eid'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(15))),
      *bold*  "ACME_CUST_ID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)                              
    /customerProfile/@id' *bold*
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50))),
        "CRET_DT" AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
        SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)                                                                                                      
    /customerProfile/@create_dt'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
    WITH
      TIME ZONE)))
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
        FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT
      TABLESPACE "ACME_DEV" ;
    CREATE
      INDEX "N98991"."ACME_CST_CRET_DT_IDX" ON "N98991"."ACME_CUST"
        "CRET_DT"
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
        FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT
      TABLESPACE "ACME_DEV" ;
    CREATE
      INDEX "N98991"."ACME_CST_EID_IDX" ON "N98991"."ACME_CUST"
        "EID"
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
        FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT
      TABLESPACE "ACME_DEV" ;
    *bold*CREATE UNIQUE INDEX "N98991"."ACME_CUST_ID_PK" ON "N98991"."ACME_CUST"
        "ACME_CUST_ID"
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE *bold*
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
        FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT
      TABLESPACE "ACME_DEV" ;
      CREATE
        INDEX "N98991"."ACME_CUST_XMLINDEX_IX" ON "N98991"."ACME_CUST"
          OBJECT_VALUE
        INDEXTYPE IS "XDB"."XMLINDEX" PARAMETERS
          'XMLTABLE ACME_CUST_IDX_TAB XMLNamespaces (''http://www.cigna.com/acme/domains/commoncontact/2011/11'' as "cm",  default ''http://www.cigna.com/acme/domains/customer/customerprofile/2011/11''),      
    ''/customerProfile''       
    columns      
    DOB date  PATH ''personInformation/cm:birthDate'',      
    FIRSTNAME varchar2(40)    PATH ''name/cm:givenName'',      
    LASTNAME varchar2(40)    PATH ''name/cm:surName'',      
    SSN varchar2(30)    PATH ''identifiers/ssn'',      
    MEMBERINFOS XMLType path ''memberInfos/memberInfo'' VIRTUAL       
    XMLTable acme_cust_lev2_idx_tab XMLNAMESPACES(default ''http://www.cigna.com/acme/domains/customer/customerprofile/2011/11''),      
    ''/memberInfo'' passing MEMBERINFOS         
    columns         
    ami varchar2(40) PATH ''ami'',        
    subscId varchar2(50) PATH ''clientRelationship/subscriberInformation/subscriberId'',        
    employeeId varchar2(50) PATH ''systemKeys/employeeId'',        
    clientId varchar2(50) PATH ''clientRelationship/clientId''      
    CREATE UNIQUE INDEX "N98991"."SYS_C00384339" ON "N98991"."ACME_CUST"
        "SYS_NC_OID$"
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
        FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT
      TABLESPACE "ACME_DEV" ;
    CREATE UNIQUE INDEX "N98991"."SYS_IL0000649948C00003$$" ON "N98991"."ACME_CUST"
        PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576
        MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST
        GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
        TABLESPACE "ACME_DEV" PARALLEL (DEGREE 0 INSTANCES 0) ;Why isn't the unique index ACME_CUST_ID_PK on the virtual column ACME_CUST_ID being used in the explain plan?
    Any input would be much appreciated, as really stumped here.
    Regards,
    Rick

    Hi Richard,
    The 10053 event appears overkill for this situation. What's the big deal?
    Set the event, run the query, unset the event, check the trace file, that's all.
    It's not overkill if it helps you understanding what happens and why an index is of no use in this situation.
    Tried the /*+ INDEX_FFS(ACME_CUST_ID_PK) */ hint in the 'nested' query.Not sure what nested query you're referring to, so if I misunderstood what you mean, just ignore the following comment.
    From what you posted earlier, it looks like you're talking about this part :
    listagg(ac.acme_cust_id,'|') WITHIN GROUP (
    ORDER BY ac.acme_cust_id,ac.acme_cust_id) CUST_IDThat's not a nested query, it's a projection. All the main work (retrieving rows) has already been done when it comes to this part.
    May just have to accept the query performance as it is...Maybe you can try something else.
    See the document : Oracle XML DB : Best Practices, page 15 ex. 8 :
    When there are multiple scalar values that need to be grouped or ordered, it is better to write it
    with XMLTable construct that projects out all columns to be ordered or grouped as shown
    below.Here's an example close to your actual requirement :
    Connected to:
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    SQL> create table xtab_cols of xmltype
      2  xmltype store as securefile binary xml;
    Table created.
    SQL> insert /*+ append */ into xtab_cols
      2  select xmlelement("ROW",
      3           xmlforest(
      4            TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER,
      5            DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID,
      6            DEFAULT_LENGTH, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,
      7            DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED, SAMPLE_SIZE,
      8            CHARACTER_SET_NAME, CHAR_COL_DECL_LENGTH,
      9            GLOBAL_STATS, USER_STATS, AVG_COL_LEN, CHAR_LENGTH, CHAR_USED,
    10            V80_FMT_IMAGE, DATA_UPGRADED, HISTOGRAM
    11           )
    12         )
    13  from dba_tab_cols
    14  where owner = 'SYS'
    15  ;
    57079 rows created.
    SQL> commit;
    Commit complete.
    SQL> set long 1000
    SQL> set pages 100
    SQL> select xmlserialize(document object_value) from xtab_cols where rownum = 1;
    XMLSERIALIZE(DOCUMENTOBJECT_VALUE)
    <ROW>
      <TABLE_NAME>ACCESS$</TABLE_NAME>
      <COLUMN_NAME>D_OBJ#</COLUMN_NAME>
      <DATA_TYPE>NUMBER</DATA_TYPE>
      <DATA_LENGTH>22</DATA_LENGTH>
      <NULLABLE>N</NULLABLE>
      <COLUMN_ID>1</COLUMN_ID>
      <NUM_DISTINCT>7454</NUM_DISTINCT>
      <LOW_VALUE>C2083A</LOW_VALUE>
      <HIGH_VALUE>C3031D18</HIGH_VALUE>
      <DENSITY>,000134156157767642</DENSITY>
      <NUM_NULLS>0</NUM_NULLS>
      <NUM_BUCKETS>1</NUM_BUCKETS>
      <LAST_ANALYZED>2012-01-28</LAST_ANALYZED>
      <SAMPLE_SIZE>34794</SAMPLE_SIZE>
      <GLOBAL_STATS>YES</GLOBAL_STATS>
      <USER_STATS>NO</USER_STATS>
      <AVG_COL_LEN>5</AVG_COL_LEN>
      <CHAR_LENGTH>0</CHAR_LENGTH>
      <V80_FMT_IMAGE>NO</V80_FMT_IMAGE>
      <DATA_UPGRADED>YES</DATA_UPGRADED>
      <HISTOGRAM>NONE</HISTOGRAM>
    </ROW>
    SQL> exec dbms_stats.gather_table_stats(user, 'XTAB_COLS');
    PL/SQL procedure successfully completed.
    SQL> set autotrace traceonly
    SQL> set timing on
    SQL> set lines 120
    SQL> select x.table_name
      2       , listagg(x.column_name, ',') within group (order by column_id)
      3  from xtab_cols t
      4     , xmltable('/ROW' passing t.object_value
      5        columns table_name  varchar2(30) path 'TABLE_NAME'
      6              , column_name varchar2(30) path 'COLUMN_NAME'
      7              , column_id   number       path 'COLUMN_ID'
      8       ) x
      9  group by x.table_name
    10  ;
    4714 rows selected.
    Elapsed: 00:00:08.25
    Execution Plan
    Plan hash value: 602782846
    | Id  | Operation           | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |           |   466M|   101G|  1580K  (3)| 05:16:04 |
    |   1 |  SORT GROUP BY      |           |   466M|   101G|  1580K  (3)| 05:16:04 |
    |   2 |   NESTED LOOPS      |           |   466M|   101G|  1552K  (1)| 05:10:32 |
    |   3 |    TABLE ACCESS FULL| XTAB_COLS | 57079 |    12M|   408   (1)| 00:00:05 |
    |   4 |    XPATH EVALUATION |           |       |       |            |          |
    Statistics
              9  recursive calls
              1  db block gets
           1713  consistent gets
              0  physical reads
             96  redo size
         773516  bytes sent via SQL*Net to client
           3873  bytes received via SQL*Net from client
            316  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
           4714  rows processedAnd of course, even better after adding a structured XML index (4714 rows fetched in 1s) :
    SQL> CREATE INDEX xtab_cols_sxi ON xtab_cols (OBJECT_VALUE) INDEXTYPE IS XDB.XMLIndex
      2  PARAMETERS (
      3  q'#XMLTable my_xtab
      4  '/ROW'
      5  columns table_name varchar2(30) path 'TABLE_NAME'
      6        , column_name varchar2(30) path 'COLUMN_NAME'
      7        , column_id number path 'COLUMN_ID' #');
    Index created.
    Elapsed: 00:00:13.42
    SQL> select x.table_name
      2       , listagg(x.column_name, ',') within group (order by column_id)
      3  from xtab_cols t
      4     , xmltable('/ROW' passing t.object_value
      5        columns table_name  varchar2(30) path 'TABLE_NAME'
      6              , column_name varchar2(30) path 'COLUMN_NAME'
      7              , column_id   number       path 'COLUMN_ID'
      8       ) x
      9  group by x.table_name
    10  ;
    4714 rows selected.
    Elapsed: 00:00:01.00
    Execution Plan
    Plan hash value: 3303494605
    | Id  | Operation          | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |         | 57520 |  3201K|   174   (3)| 00:00:03 |
    |   1 |  SORT GROUP BY     |         | 57520 |  3201K|   174   (3)| 00:00:03 |
    |   2 |   TABLE ACCESS FULL| MY_XTAB | 57520 |  3201K|   171   (1)| 00:00:03 |
    Note
       - dynamic sampling used for this statement (level=2)
    Statistics
            297  recursive calls
              1  db block gets
            989  consistent gets
              0  physical reads
            176  redo size
         773516  bytes sent via SQL*Net to client
           3873  bytes received via SQL*Net from client
            316  SQL*Net roundtrips to/from client
             21  sorts (memory)
              0  sorts (disk)
           4714  rows processed

  • How to create index to speed up query on XMLTYPE table

    I have a table of XMLTYPE called gary_pass_xml. What kind of index can I create on the table to speed up this query.
    SELECT (Extract(Value(FareGroupNodes),'/FareGroup')) FareGroup
    FROM GARY_PASS_XML tx,
    TABLE(XMLSequence(Extract(Value(tx),'/FareSearchRS/FareGroup'))) FareGroupNodes
    WHERE existsnode(value(tx),'/FareSearchRS/FareGroup') = 1

    I have a table of XMLTYPE called gary_pass_xml. What kind of index can I create on the table to speed up this query.
    SELECT (Extract(Value(FareGroupNodes),'/FareGroup')) FareGroup
    FROM GARY_PASS_XML tx,
    TABLE(XMLSequence(Extract(Value(tx),'/FareSearchRS/FareGroup'))) FareGroupNodes
    WHERE existsnode(value(tx),'/FareSearchRS/FareGroup') = 1

  • Is this query on XMLTYPE the most performant ?

    Hello,
    We are in 11gR2
    and we built a process for loading XML files that I think are very complex (I hope so)
    We about about 600 similar XML files to load every night.
    The XML file is saved under a XMLTYPE table and we attached a XSD Schema on it.
    One of the queries we built for selecting XMLTYPE data uses several outer joins on the XML. And I think I should find a way for increasing performance on the query
    Here is the details (sometimes huge in volume) :
    1) The query I would like to improve :
    Depending on data in the XML file, the SELECT duration can go from 3 minutes to more than 4 hours !
      select DISTINCT UPPER(t2.ressource_code)
      , CASE WHEN ( t5.isWorkDay = 'false' AND t5.day IS NOT NULL
                    AND ( to_date( replace(t5.day, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS')
                          BETWEEN to_date( replace(t4.taux_start_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS')
                              AND to_date( replace(t4.taux_end_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS'))
             THEN to_date( replace(t5.day, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS')
             ELSE to_date( replace(t4.taux_start_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS') END day_start
      , CASE WHEN ( t5.isWorkDay = 'false' AND t5.day IS NOT NULL
                    AND ( to_date( replace(t5.day, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS')
                          BETWEEN to_date( replace(t4.taux_start_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS')
                              AND to_date( replace(t4.taux_end_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS'))
             THEN to_date( replace(t5.day, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS')+1
             ELSE to_date( replace(t4.taux_end_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS') END day_finish
      , DECODE( t5.isWorkDay, NULL, CASE WHEN (to_number( t4.rate)>0) THEN 'true' ELSE 'false' END, t5.isWorkDay)  isWorkDay
      , DECODE( t5.isWorkDay, NULL, TO_CHAR( to_date( replace(t4.taux_start_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS'), t6.shift_start) shift_start
      , DECODE( t5.isWorkDay, NULL, TO_CHAR( to_date( replace(t4.taux_end_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS'), t6.shift_finish) shift_finish
      , DECODE( UPPER(t5.dayOfWeek), 'MON', 'LUNDI', 'TUE', 'MARDI', 'WED', 'MERCREDI', 'THU', 'JEUDI', 'FRI', 'VENDREDI', 'SAT', 'SAMEDI', 'SUN', 'DIMANCHE', NULL, NULL) dayOfWeek
      , SYSDATE
      , t1.tache_uid, t1.tache_code, t1.tache_desc
      , t3.curve_name
      , to_number( t4.rate) activity
      FROM WORKBENCH_PROJECT_TABLE t
      , xmltable( xmlNamespaces( default 'http://www.oracle.com/xsd/projet.xsd')
      , '/WORKBENCH_PROJECT/Projects/Project/Tasks/Task' passing OBJECT_VALUE
      columns tache_UID          varchar2(70) path '@UID'
      , tache_code         varchar2(150) path '@taskID'
      , tache_desc         varchar2(150) path '@name'
      , activites_xml      xmltype      path 'Assignments'
      ) t1
      , xmltable( xmlNamespaces( default 'http://www.oracle.com/xsd/projet.xsd')
      , '/Assignments/*' passing t1.activites_xml
      columns ressource_code     varchar2(50) path '@resourceID'
      , curves_xml         xmltype      path 'Curve'
      ) t2
      , xmltable( xmlNamespaces( default 'http://www.oracle.com/xsd/projet.xsd')
      , '/Curve' passing t2.curves_xml
      columns curve_name         varchar2(50) path '@name'
      , segments_xml       xmltype      path 'Segments'
      ) t3
      , xmltable( xmlNamespaces( default 'http://www.oracle.com/xsd/projet.xsd')
      , '/Segments/*' passing t3.segments_xml
        columns rate               varchar2(50) path '@rate'
      , taux_start_date         varchar2(20) path '@start'
      , taux_end_date           varchar2(20) path '@finish'
      , calendar_days_xml       xmltype      path 'Calendar/Days'
      ) t4
      , xmltable( xmlNamespaces( default 'http://www.oracle.com/xsd/projet.xsd')
      , '/Days/*' passing t4.calendar_days_xml
        columns dayOfWeek       varchar2(50) path '@dayOfWeek'
      , isWorkDay               varchar2(20) path '@isWorkDay'
      , DAY                     varchar2(20) path '@start'
      , shift_xml               xmltype      path 'Shifts'
      ) (+) t5
      , xmltable( xmlNamespaces( default 'http://www.oracle.com/xsd/projet.xsd')
      , 'Shifts/Shift'        passing t5.shift_xml
         columns shift_start  varchar2(20) path '@start'
               , shift_finish varchar2(20) path '@finish'
      ) (+) t6; Here is the XSD schema :
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:xdb="http://xmlns.oracle.com/xdb"
             xmlns="http://www.oracle.com/xsd/projet.xsd"
             targetNamespace="http://www.oracle.com/xsd/projet.xsd"
             elementFormDefault="unqualified"
             xdb:storeVarrayAsTable="true">
      <xsd:element name="WORKBENCH_PROJECT" xdb:defaultTable="WORKBENCH_PROJECT_TABLE">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="BaseCalendars"/>
            <xsd:element ref="PoolResources"/>
            <xsd:element ref="Projects"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="BaseCalendars" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Calendar" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="PoolResources" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="PoolResource" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="PoolResource" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Calendar"/>
            <xsd:element ref="Curve"/>
            <xsd:element ref="Notes" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="category" type="xsd:string"/>
          <xsd:attribute name="emailAddress" type="xsd:string"/>
          <xsd:attribute name="employmentType" type="xsd:integer"/>
          <xsd:attribute name="description" type="xsd:string"/>
          <xsd:attribute name="firstName" type="xsd:string"/>
          <xsd:attribute name="fullName" type="xsd:string"/>
          <xsd:attribute name="hireDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="inputTypeCode" type="xsd:integer"/>
          <xsd:attribute name="isActive" type="xsd:boolean"/>
          <xsd:attribute name="isExternal" type="xsd:boolean"/>
          <xsd:attribute name="isRole" type="xsd:boolean"/>
          <xsd:attribute name="lastName" type="xsd:string"/>
          <xsd:attribute name="managerUserName" type="xsd:string"/>
          <xsd:attribute name="modBy" type="xsd:string"/>
          <xsd:attribute name="openForTimeEntry" type="xsd:boolean"/>
          <xsd:attribute name="resourceId" type="xsd:string"/>
          <xsd:attribute name="resourceType" type="xsd:integer"/>
          <xsd:attribute name="roleID" type="xsd:string"/>
          <xsd:attribute name="terminationDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="trackMode" type="xsd:integer"/>
          <xsd:attribute name="userFlag1" type="xsd:boolean"/>
          <xsd:attribute name="userFlag2" type="xsd:boolean"/>
          <xsd:attribute name="userNumber1" type="xsd:decimal"/>
          <xsd:attribute name="userNumber2" type="xsd:decimal"/>
          <xsd:attribute name="userText1" type="xsd:string"/>
          <xsd:attribute name="userText2" type="xsd:string"/>
          <xsd:attribute name="userText3" type="xsd:string"/>
          <xsd:attribute name="userText4" type="xsd:string"/>
          <xsd:attribute name="userText5" type="xsd:string"/>
          <xsd:attribute name="userText6" type="xsd:string"/>
          <xsd:attribute name="userText7" type="xsd:string"/>
          <xsd:attribute name="userText8" type="xsd:string"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Projects" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Project" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Project" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Baselines" minOccurs="0"/>
            <xsd:element ref="Notes" minOccurs="0"/>
            <xsd:element ref="Resources" minOccurs="0"/>
            <xsd:element ref="Tasks" minOccurs="0"/>
            <xsd:element ref="BaselineDetails" minOccurs="0"/>
            <xsd:element ref="Dependencies" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="UID"/>
          <xsd:attribute name="active" type="xsd:boolean"/>
          <xsd:attribute name="asOf" type="xsd:NMTOKEN"/>
          <xsd:attribute name="approved" type="xsd:boolean"/>
          <xsd:attribute name="baseFinish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="baseStart" type="xsd:NMTOKEN"/>
          <xsd:attribute name="baseTime" type="xsd:NMTOKEN"/>
          <xsd:attribute name="budget" type="xsd:double"/>
          <xsd:attribute name="closed" type="xsd:boolean"/>
          <xsd:attribute name="cpmType" type="xsd:integer"/>
          <xsd:attribute name="department" type="xsd:string"/>
          <xsd:attribute name="description" type="xsd:string"/>
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="finishImposed" type="xsd:boolean"/>
          <xsd:attribute name="format" type="xsd:integer"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="name" type="xsd:string"/>
          <xsd:attribute name="openForTimeEntry" type="xsd:boolean"/>
          <xsd:attribute name="priority" type="xsd:integer"/>
          <xsd:attribute name="projectType" type="xsd:integer"/>
          <xsd:attribute name="program" type="xsd:boolean"/>
          <xsd:attribute name="projectID" type="xsd:string"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
          <xsd:attribute name="startImposed" type="xsd:boolean"/>
          <xsd:attribute name="status" type="xsd:integer"/>
          <xsd:attribute name="trackMode" type="xsd:integer"/>
          <xsd:attribute name="userText1" type="xsd:string"/>
          <xsd:attribute name="userText2" type="xsd:string"/>
          <xsd:attribute name="userText3" type="xsd:string"/>
          <xsd:attribute name="userText4" type="xsd:string"/>
          <xsd:attribute name="userText5" type="xsd:string"/>
          <xsd:attribute name="userText6" type="xsd:string"/>
          <xsd:attribute name="userText7" type="xsd:string"/>
          <xsd:attribute name="userText8" type="xsd:string"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Baselines" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Baseline" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Baseline" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:attribute name="code" type="xsd:string"/>
          <xsd:attribute name="current" type="xsd:boolean"/>
          <xsd:attribute name="description"/>
          <xsd:attribute name="name" type="xsd:string"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Resources" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Resource" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Resource" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Curve" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element ref="BaselineDetails" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
          <xsd:attribute name="availFrom" type="xsd:NMTOKEN"/>
          <xsd:attribute name="availTo" type="xsd:NMTOKEN"/>
          <xsd:attribute name="bookingStatus" type="xsd:integer"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="openForTimeEntry" type="xsd:boolean"/>
          <xsd:attribute name="requestStatus" type="xsd:integer"/>
          <xsd:attribute name="resourceID" type="xsd:string"/>
          <xsd:attribute name="roleID" type="xsd:string"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Tasks" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Task" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Task" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Assignments" minOccurs="0"/>
            <xsd:element ref="BaselineDetails" minOccurs="0"/>
            <xsd:element ref="Constraints" minOccurs="0"/>
            <xsd:element ref="Notes" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="UID"/>
          <xsd:attribute name="taskID" type="xsd:string"/>
          <xsd:attribute name="baseFinish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="baseStart" type="xsd:NMTOKEN"/>
          <xsd:attribute name="baseTime" type="xsd:NMTOKEN"/>
          <xsd:attribute name="baselineDuration" type="xsd:decimal"/>
          <xsd:attribute name="category" type="xsd:string"/>
          <xsd:attribute name="critical" type="xsd:boolean"/>
          <xsd:attribute name="earlyFinish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="earlyStart" type="xsd:NMTOKEN"/>
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="fixed" type="xsd:boolean"/>
          <xsd:attribute name="guidelines" type="xsd:string"/>
          <xsd:attribute name="key" type="xsd:boolean"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="lateFinish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="lateStart" type="xsd:NMTOKEN"/>
          <xsd:attribute name="locked" type="xsd:boolean"/>
          <xsd:attribute name="methodID" type="xsd:string"/>
          <xsd:attribute name="milestone" type="xsd:boolean"/>
          <xsd:attribute name="name" type="xsd:string"/>
          <xsd:attribute name="outlineLevel" type="xsd:integer"/>
          <xsd:attribute name="percComp" type="xsd:decimal"/>
          <xsd:attribute name="priority" type="xsd:string"/>
          <xsd:attribute name="proxy" type="xsd:boolean"/>
          <xsd:attribute name="shortName" type="xsd:string"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
          <xsd:attribute name="status" type="xsd:integer"/>
          <xsd:attribute name="summary" type="xsd:boolean"/>
          <xsd:attribute name="totalSlack" type="xsd:double"/>
          <xsd:attribute name="unplanned" type="xsd:boolean"/>
          <xsd:attribute name="userText1" type="xsd:string"/>
          <xsd:attribute name="userText2" type="xsd:string"/>
          <xsd:attribute name="userText3" type="xsd:string"/>
          <xsd:attribute name="userText4" type="xsd:string"/>
          <xsd:attribute name="userText5" type="xsd:string"/>
          <xsd:attribute name="userText6" type="xsd:string"/>
          <xsd:attribute name="userText7" type="xsd:string"/>
          <xsd:attribute name="userText8" type="xsd:string"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Assignments" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Assignment" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Assignment" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Curve" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element ref="BaselineDetails" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="actualThrough" type="xsd:NMTOKEN"/>
          <xsd:attribute name="actualWork" type="xsd:double"/>
          <xsd:attribute name="baselineWork" type="xsd:double"/>
          <xsd:attribute name="estMax" type="xsd:double"/>
          <xsd:attribute name="estPattern" type="xsd:integer"/>
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="pendActSum" type="xsd:double"/>
          <xsd:attribute name="pendEstSum" type="xsd:double"/>
          <xsd:attribute name="remainingWork" type="xsd:double"/>
          <xsd:attribute name="resourceID" type="xsd:string"/>
          <xsd:attribute name="roleID" type="xsd:string"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
          <xsd:attribute name="status" type="xsd:integer"/>
          <xsd:attribute name="unplanned" type="xsd:boolean"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Constraints" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Constraint" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Constraint" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="time" type="xsd:NMTOKEN"/>
          <xsd:attribute name="type" type="xsd:integer"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Notes" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Note" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Note" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:attribute name="category" type="xsd:string"/>
          <xsd:attribute name="content" type="xsd:string"/>
          <xsd:attribute name="createdBy" type="xsd:string"/>
          <xsd:attribute name="createdDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Dependencies" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Dependency" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Dependency" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:attribute name="lag" type="xsd:decimal"/>
          <xsd:attribute name="lagType" type="xsd:integer"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="predecessorID" type="xsd:string"/>
          <xsd:attribute name="predecessorUID"/>
          <xsd:attribute name="startFinishType" type="xsd:integer"/>
          <xsd:attribute name="successorID" type="xsd:string"/>
          <xsd:attribute name="successorUID"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Calendar" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Days" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="baseCalendar"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="name"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Days" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Day" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Day" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Shifts" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="dayOfWeek" type="xsd:string"/>
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="isWorkDay" type="xsd:boolean"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Shifts" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Shift" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Shift" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Curve" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Segments" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="default" type="xsd:double"/>
          <xsd:attribute name="name" type="xsd:string"/>
          <xsd:attribute name="type" type="xsd:integer"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Segments" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Segment" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Segment" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Calendar" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="rate" type="xsd:double"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="BaselineDetails" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="BaselineDetail" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="BaselineDetail" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Curve" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
          <xsd:attribute name="baselineCode" type="xsd:string"/>
          <xsd:attribute name="costSum" type="xsd:double"/>
          <xsd:attribute name="duration" type="xsd:double"/>
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
          <xsd:attribute name="usageSum" type="xsd:double"/>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>3) and one of the smallest XML ... (I can send you a bigger one, where you could notice the query duration )
        "Your message exceeds the maximum length of 30000 characters."I can email you an XML file, I failed to upload the smallest XML file !!!!
    Well, I hope that's clear enough ad that you could provide me help and advices
    Thanks a lot in advance,
    Olivier

    connect / as sysdba
    set define on
    set timing on
    -- Define variables for USERNAME, TABLESPACES and XMLDIR that represents the base directory where a 'xsd' directory
    -- exists that contains the called XML schema used in this script to be registered that creates the XMLTYPE OR table
    def USERNAME = cap
    def PASSWORD = &USERNAME
    -- def XMLDIR = 'C:\Temp'
    def USER_TABSPACE = USERS
    def TEMP_TABSPACE = TEMP
    -- End declaritive section
    drop user &USERNAME cascade
    grant create any directory, drop any directory, connect, resource, create synonym, alter session, create view to &USERNAME identified by &PASSWORD
    alter user &USERNAME default tablespace &USER_TABSPACE temporary tablespace &TEMP_TABSPACE
    connect &USERNAME/&PASSWORD
    -- create or replace directory XMLDIR as '&XMLDIR/xsd'
    select * from v$version
    DECLARE
      V_XMLSCHEMA CLOB := '<?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:xdb="http://xmlns.oracle.com/xdb"
             xmlns="http://www.oracle.com/xsd/projet.xsd"
             targetNamespace="http://www.oracle.com/xsd/projet.xsd"
             elementFormDefault="unqualified"
             xdb:storeVarrayAsTable="true">
      <xsd:element name="WORKBENCH_PROJECT" xdb:defaultTable="WORKBENCH_PROJECT_TABLE">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="BaseCalendars"/>
            <xsd:element ref="PoolResources"/>
            <xsd:element ref="Projects"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="BaseCalendars" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Calendar" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="PoolResources" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="PoolResource" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="PoolResource" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Calendar"/>
            <xsd:element ref="Curve"/>
            <xsd:element ref="Notes" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="category" type="xsd:string"/>
          <xsd:attribute name="emailAddress" type="xsd:string"/>
          <xsd:attribute name="employmentType" type="xsd:integer"/>
          <xsd:attribute name="description" type="xsd:string"/>
          <xsd:attribute name="firstName" type="xsd:string"/>
          <xsd:attribute name="fullName" type="xsd:string"/>
          <xsd:attribute name="hireDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="inputTypeCode" type="xsd:integer"/>
          <xsd:attribute name="isActive" type="xsd:boolean"/>
          <xsd:attribute name="isExternal" type="xsd:boolean"/>
          <xsd:attribute name="isRole" type="xsd:boolean"/>
          <xsd:attribute name="lastName" type="xsd:string"/>
          <xsd:attribute name="managerUserName" type="xsd:string"/>
          <xsd:attribute name="modBy" type="xsd:string"/>
          <xsd:attribute name="openForTimeEntry" type="xsd:boolean"/>
          <xsd:attribute name="resourceId" type="xsd:string"/>
          <xsd:attribute name="resourceType" type="xsd:integer"/>
          <xsd:attribute name="roleID" type="xsd:string"/>
          <xsd:attribute name="terminationDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="trackMode" type="xsd:integer"/>
          <xsd:attribute name="userFlag1" type="xsd:boolean"/>
          <xsd:attribute name="userFlag2" type="xsd:boolean"/>
          <xsd:attribute name="userNumber1" type="xsd:decimal"/>
          <xsd:attribute name="userNumber2" type="xsd:decimal"/>
          <xsd:attribute name="userText1" type="xsd:string"/>
          <xsd:attribute name="userText2" type="xsd:string"/>
          <xsd:attribute name="userText3" type="xsd:string"/>
          <xsd:attribute name="userText4" type="xsd:string"/>
          <xsd:attribute name="userText5" type="xsd:string"/>
          <xsd:attribute name="userText6" type="xsd:string"/>
          <xsd:attribute name="userText7" type="xsd:string"/>
          <xsd:attribute name="userText8" type="xsd:string"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Projects" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Project" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Project" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Baselines" minOccurs="0"/>
            <xsd:element ref="Notes" minOccurs="0"/>
            <xsd:element ref="Resources" minOccurs="0"/>
            <xsd:element ref="Tasks" minOccurs="0"/>
            <xsd:element ref="BaselineDetails" minOccurs="0"/>
            <xsd:element ref="Dependencies" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="UID"/>
          <xsd:attribute name="active" type="xsd:boolean"/>
          <xsd:attribute name="asOf" type="xsd:NMTOKEN"/>
          <xsd:attribute name="approved" type="xsd:boolean"/>
          <xsd:attribute name="baseFinish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="baseStart" type="xsd:NMTOKEN"/>
          <xsd:attribute name="baseTime" type="xsd:NMTOKEN"/>
          <xsd:attribute name="budget" type="xsd:double"/>
          <xsd:attribute name="closed" type="xsd:boolean"/>
          <xsd:attribute name="cpmType" type="xsd:integer"/>
          <xsd:attribute name="department" type="xsd:string"/>
          <xsd:attribute name="description" type="xsd:string"/>
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="finishImposed" type="xsd:boolean"/>
          <xsd:attribute name="format" type="xsd:integer"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="name" type="xsd:string"/>
          <xsd:attribute name="openForTimeEntry" type="xsd:boolean"/>
          <xsd:attribute name="priority" type="xsd:integer"/>
          <xsd:attribute name="projectType" type="xsd:integer"/>
          <xsd:attribute name="program" type="xsd:boolean"/>
          <xsd:attribute name="projectID" type="xsd:string"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
          <xsd:attribute name="startImposed" type="xsd:boolean"/>
          <xsd:attribute name="status" type="xsd:integer"/>
          <xsd:attribute name="trackMode" type="xsd:integer"/>
          <xsd:attribute name="userText1" type="xsd:string"/>
          <xsd:attribute name="userText2" type="xsd:string"/>
          <xsd:attribute name="userText3" type="xsd:string"/>
          <xsd:attribute name="userText4" type="xsd:string"/>
          <xsd:attribute name="userText5" type="xsd:string"/>
          <xsd:attribute name="userText6" type="xsd:string"/>
          <xsd:attribute name="userText7" type="xsd:string"/>
          <xsd:attribute name="userText8" type="xsd:string"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Baselines" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Baseline" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Baseline" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:attribute name="code" type="xsd:string"/>
          <xsd:attribute name="current" type="xsd:boolean"/>
          <xsd:attribute name="description"/>
          <xsd:attribute name="name" type="xsd:string"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Resources" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Resource" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Resource" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Curve" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element ref="BaselineDetails" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
          <xsd:attribute name="availFrom" type="xsd:NMTOKEN"/>
          <xsd:attribute name="availTo" type="xsd:NMTOKEN"/>
          <xsd:attribute name="bookingStatus" type="xsd:integer"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="openForTimeEntry" type="xsd:boolean"/>
          <xsd:attribute name="requestStatus" type="xsd:integer"/>
          <xsd:attribute name="resourceID" type="xsd:string"/>
          <xsd:attribute name="roleID" type="xsd:string"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Tasks" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Task" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Task" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Assignments" minOccurs="0"/>
            <xsd:element ref="BaselineDetails" minOccurs="0"/>
            <xsd:element ref="Constraints" minOccurs="0"/>
            <xsd:element ref="Notes" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="UID"/>
          <xsd:attribute name="taskID" type="xsd:string"/>
          <xsd:attribute name="baseFinish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="baseStart" type="xsd:NMTOKEN"/>
          <xsd:attribute name="baseTime" type="xsd:NMTOKEN"/>
          <xsd:attribute name="baselineDuration" type="xsd:decimal"/>
          <xsd:attribute name="category" type="xsd:string"/>
          <xsd:attribute name="critical" type="xsd:boolean"/>
          <xsd:attribute name="earlyFinish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="earlyStart" type="xsd:NMTOKEN"/>
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="fixed" type="xsd:boolean"/>
          <xsd:attribute name="guidelines" type="xsd:string"/>
          <xsd:attribute name="key" type="xsd:boolean"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="lateFinish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="lateStart" type="xsd:NMTOKEN"/>
          <xsd:attribute name="locked" type="xsd:boolean"/>
          <xsd:attribute name="methodID" type="xsd:string"/>
          <xsd:attribute name="milestone" type="xsd:boolean"/>
          <xsd:attribute name="name" type="xsd:string"/>
          <xsd:attribute name="outlineLevel" type="xsd:integer"/>
          <xsd:attribute name="percComp" type="xsd:decimal"/>
          <xsd:attribute name="priority" type="xsd:string"/>
          <xsd:attribute name="proxy" type="xsd:boolean"/>
          <xsd:attribute name="shortName" type="xsd:string"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
          <xsd:attribute name="status" type="xsd:integer"/>
          <xsd:attribute name="summary" type="xsd:boolean"/>
          <xsd:attribute name="totalSlack" type="xsd:double"/>
          <xsd:attribute name="unplanned" type="xsd:boolean"/>
          <xsd:attribute name="userText1" type="xsd:string"/>
          <xsd:attribute name="userText2" type="xsd:string"/>
          <xsd:attribute name="userText3" type="xsd:string"/>
          <xsd:attribute name="userText4" type="xsd:string"/>
          <xsd:attribute name="userText5" type="xsd:string"/>
          <xsd:attribute name="userText6" type="xsd:string"/>
          <xsd:attribute name="userText7" type="xsd:string"/>
          <xsd:attribute name="userText8" type="xsd:string"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Assignments" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Assignment" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Assignment" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Curve" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element ref="BaselineDetails" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="actualThrough" type="xsd:NMTOKEN"/>
          <xsd:attribute name="actualWork" type="xsd:double"/>
          <xsd:attribute name="baselineWork" type="xsd:double"/>
          <xsd:attribute name="estMax" type="xsd:double"/>
          <xsd:attribute name="estPattern" type="xsd:integer"/>
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="pendActSum" type="xsd:double"/>
          <xsd:attribute name="pendEstSum" type="xsd:double"/>
          <xsd:attribute name="remainingWork" type="xsd:double"/>
          <xsd:attribute name="resourceID" type="xsd:string"/>
          <xsd:attribute name="roleID" type="xsd:string"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
          <xsd:attribute name="status" type="xsd:integer"/>
          <xsd:attribute name="unplanned" type="xsd:boolean"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Constraints" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Constraint" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Constraint" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="time" type="xsd:NMTOKEN"/>
          <xsd:attribute name="type" type="xsd:integer"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Notes" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Note" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Note" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:attribute name="category" type="xsd:string"/>
          <xsd:attribute name="content" type="xsd:string"/>
          <xsd:attribute name="createdBy" type="xsd:string"/>
          <xsd:attribute name="createdDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Dependencies" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Dependency" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Dependency" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:attribute name="lag" type="xsd:decimal"/>
          <xsd:attribute name="lagType" type="xsd:integer"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="predecessorID" type="xsd:string"/>
          <xsd:attribute name="predecessorUID"/>
          <xsd:attribute name="startFinishType" type="xsd:integer"/>
          <xsd:attribute name="successorID" type="xsd:string"/>
          <xsd:attribute name="successorUID"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Calendar" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Days" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="baseCalendar"/>
          <xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
          <xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
          <xsd:attribute name="name"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Days" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Day" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Day" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Shifts" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="dayOfWeek" type="xsd:string"/>
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="isWorkDay" type="xsd:boolean"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Shifts" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Shift" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Shift" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Curve" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Segments" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="default" type="xsd:double"/>
          <xsd:attribute name="name" type="xsd:string"/>
          <xsd:attribute name="type" type="xsd:integer"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Segments" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Segment" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Segment" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Calendar" minOccurs="0"/>
          </xsd:sequence>
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="rate" type="xsd:double"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="BaselineDetails" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="BaselineDetail" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="BaselineDetail" xdb:defaultTable="">
        <xsd:complexType xdb:maintainDOM="false">
          <xsd:sequence>
            <xsd:element ref="Curve" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
          <xsd:attribute name="baselineCode" type="xsd:string"/>
          <xsd:attribute name="costSum" type="xsd:double"/>
          <xsd:attribute name="duration" type="xsd:double"/>
          <xsd:attribute name="finish" type="xsd:NMTOKEN"/>
          <xsd:attribute name="start" type="xsd:NMTOKEN"/>
          <xsd:attribute name="usageSum" type="xsd:double"/>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>' ;
    BEGIN
      dbms_xmlschema.registerSchema
        schemaurl       => 'http://www.oracle.com/xsd/projet.xsd',
        schemadoc       => V_XMLSCHEMA,
        local           => TRUE,
        genTypes        => TRUE,
        genBean         => FALSE,
        genTables       => TRUE,
        enablehierarchy => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE,
        owner           => user
    END;
    /

  • Help Query returns XMLType

    I'm unable get XML output from the most basic of queries. I'm currently working through the Sql In Xml out document. Everytime i try to output xml i get a list (without errors) of
    EMPLOYEE
    <Xmltype>
    <Xmltype>
    <Xmltype>
    <Xmltype>
    <Xmltype>
    for each record. Can anyone help.
    Im running 10g release 2.

    A couple more questions
    First, is the XML stored in the table as XMLType column with a schema?
    Second, in sqplus, on 10R2, I just ran the following query, try it and see if what you get.
    select xmlforest(object_name as "name") from user_objects where object_type = 'TABLE' and rownum < 5;
    XMLFOREST(OBJECT_NAMEAS"NAME")
    <name>BIN$+1aDxmVbQIau51oiplxCAw==$0</name>
    <name>BIN$+3Y2EpX4TvGY4j1SIGBAMQ==$0</name>
    <name>BIN$+AugUYpGSS29uaP5DnYsZQ==$0</name>
    <name>BIN$+ptFT7gqTX2GgNrndS5azw==$0</name>
    Elapsed: 00:00:00.02
    of course your names will vary.
    Scott

  • Query against XMLType

    I'm hung up on something that I suspect is very easy, but I have little experience working with XML in the database and think I've just stared at it too long.
    I have an XML document (fragment below) stored as an XMLType in a 10g R2 database table and I want to return the following result set from a query against the document:
    PAGE_ID PAGE_SUBMISSION_FIELD
    21 F39EF21
    21 F85FG3E
    21 F73EF58
    21 FA4939F
    22 FDE77A4
    22 FF3AD33
    Here is a fragment of the XML document:
    <root-interface>
    <page-group>
    <display-page validation-state="new">
    <id>21</id>
    <page-submission-fields>
    <page-submission-field>F39EF21</page-submission-field>
    <page-submission-field>F85FG3E</page-submission-field>
    <page-submission-field>F73EF58</page-submission-field>
    <page-submission-field>FA4939F</page-submission-field>
    </page-submission-fields>
    </display-page>
    <display-page validation-state="new">
    <id>22</id>
    <page-submission-fields>
    <page-submission-field>FDE77A4</page-submission-field>
    <page-submission-field>FF3AD33</page-submission-field>
    </page-submission-fields>
    </display-page>
    </page-group>
    </root-interface>
    Here is the table in which it is stored:
    desc cms_session_interfaces
    Name Null? Type
    SESSION_ID NOT NULL NUMBER
    INTERFACE_ID NOT NULL NUMBER
    CREATED NOT NULL DATE
    LAST_ACCESSED DATE
    INTERFACE_XML SYS.XMLTYPE
    Here is a close as I've come with a query:
    select extract(value(display_pages), '//id/text()').getStringVal() page_id,
    extract(value(display_pages), '//page-submission-fields/page-submission-field') page_submission_field
    from cms_session_interfaces csi,
    table(xmlsequence(extract(csi.interface_xml, '//root-interface/page-group/display-page'))) display_pages
    where csi.session_id = 41
    and csi.interface_id = 596
    (the specified session_id and interface_id are just for testing purposes)
    This returns two rows consisting of the PAGE_ID and an object of XMLType containing the page-submission fields. Almost there, but not quite; any suggestions would be appreciated.

    As Marco said, xmltable is very handy:
    SQL> with cms_session_interfaces as (
      2  select XMLType('
      3  <root-interface>
      4    <page-group>
      5      <display-page validation-state="new">
      6        <id>21</id>
      7        <page-submission-fields>
      8          <page-submission-field>F39EF21</page-submission-field>
      9          <page-submission-field>F85FG3E</page-submission-field>
    10          <page-submission-field>F73EF58</page-submission-field>
    11          <page-submission-field>FA4939F</page-submission-field>
    12        </page-submission-fields>
    13      </display-page>
    14      <display-page validation-state="new">
    15        <id>22</id>
    16        <page-submission-fields>
    17          <page-submission-field>FDE77A4</page-submission-field>
    18          <page-submission-field>FF3AD33</page-submission-field>
    19        </page-submission-fields>
    20      </display-page>
    21          </page-group>
    22  </root-interface>') interface_xml
    23  from dual)
    24  select page.id,fields.field
    25  from cms_session_interfaces csi,
    26  xmltable('//root-interface/page-group/display-page'
    27   passing interface_xml
    28   columns
    29    id varchar2(10) path 'id',
    30    page_fields xmltype path 'page-submission-fields') page,
    31  xmltable('/page-submission-fields/page-submission-field'
    32   passing page_fields
    33   columns
    34    field varchar2(25) path '.') fields
    35  /
    ID         FIELD
    21         F39EF21
    21         F85FG3E
    21         F73EF58
    21         FA4939F
    22         FDE77A4
    22         FF3AD33
    6 rows selected.Best regards
    Maxim

Maybe you are looking for