XQuery all docs in an XMLType column?
I created the following table:
create table security(sdoc XMLType)
I inserted xml files:
insert into security values (xmltype(?))
Now I want to query the xml docs using XQuery.
Is there a way to query all xml docs in a XMLType column with an XQuery expression at once?
Like:
for $i in function(sdoc)
where $i/Symbol = "ABCD"
return $i
Is there a function that returns an XML Sequence that consist of all docs in the XMLType column? Or do I have to adopt the query tuple by tuple?
I looked in the 10g Release 2 documentation and found the function XMLQuery, but my understanding was that the XMLQuery-function only takes one tuple (one doc). Is that right?
I'm using JDBC to connect to the database. Do you have a hint how I can use the XQuery inside XMLQuery in my case?
Thanks in advance
thx for your help!! But I still have a problem.
I created an XMLType table:
create table security of xmltype
I inserted 10 xml docs:
insert into security values(xmltype(?))
The xml docs are like this:
<?xml version="1.0" encoding="US-ASCII"?>
<Security id="10000">
<Symbol>ATRK</Symbol>
<Name>@Track Communications, Inc.</Name>
<ShortName>ATRK</ShortName>
<SecurityType>Stock</SecurityType>
<SecurityInformation><StockInformation><Sector>Healthcare</Sector>
<Industry>Constr.-Supplies&Fixtures</Industry>
<Industry>BusinessServices</Industry>
<Industry>Auto&TruckManufacturers</Industry>
<Industry>FoodProcessing</Industry>
<Industry>OilWellServices&Equipment</Industry>
<Industry>Oil&Gas-Integrated</Industry>
<Category Capitalization="Large" Class="Blend"></Category>
<OutstShares>221841392</OutstShares>
</StockInformation>
<Description>
</Description>
</SecurityInformation>
<Price><LastTrade>91.5358</LastTrade>
<Ask>92.1646</Ask>
<Bid>91.2767</Bid>
<Price50DayAvg>105.3278</Price50DayAvg>
<Price200DayAvg>96.2106</Price200DayAvg>
<PriceToday><PreviousClose>91.5358</PreviousClose>
<Open>94.6341</Open>
<High>99.3516</High>
<Low>93.8742</Low>
</PriceToday>
<Price52week><Price52week-low>93.8742</Price52week-low>
<Price52week-low-date>2004-09-10</Price52week-low-date>
<Price52week-high>105.3278</Price52week-high>
<Price52week-high-date>2004-08-01</Price52week-high-date>
</Price52week>
</Price>
<PE>20.38</PE>
<Yield>6.95</Yield>
<DivPerShare>4.75</DivPerShare>
</Security>
But when I run the query:
Select xmlquery('for $i in ora:view("security")/Security/Symbol return $i' returning content).extract('/*') RESULT from security
I'm getting this:
<Symbol>TDSC</Symbol>
<Symbol>ATRK</Symbol>
<Symbol>OIIM</Symbol>
<Symbol>CTAC</Symbol>
<Symbol>FLWS</Symbol>
<Symbol>ATTY</Symbol>
<Symbol>FCCY</Symbol>
<Symbol>SRCE</Symbol>
<Symbol>TFSM</Symbol>
<Symbol>COMS</Symbol>
<Symbol>TDSC</Symbol>
<Symbol>ATRK</Symbol>
<Symbol>OIIM</Symbol>
<Symbol>CTAC</Symbol>
<Symbol>FLWS</Symbol>
<Symbol>ATTY</Symbol>
<Symbol>FCCY</Symbol>
<Symbol>SRCE</Symbol>
<Symbol>TFSM</Symbol>
<Symbol>COMS</Symbol>
<Symbol>TDSC</Symbol>
<Symbol>ATRK</Symbol>
<Symbol>OIIM</Symbol>
<Symbol>CTAC</Symbol>
<Symbol>FLWS</Symbol>
<Symbol>ATTY</Symbol>
<Symbol>FCCY</Symbol>
<Symbol>SRCE</Symbol>
<Symbol>TFSM</Symbol>
<Symbol>COMS</Symbol>
<Symbol>TDSC</Symbol>
<Symbol>ATRK</Symbol>
<Symbol>OIIM</Symbol>
<Symbol>CTAC</Symbol>
<Symbol>FLWS</Symbol>
<Symbol>ATTY</Symbol>
<Symbol>FCCY</Symbol>
<Symbol>SRCE</Symbol>
<Symbol>TFSM</Symbol>
<Symbol>COMS</Symbol>
<Symbol>TDSC</Symbol>
<Symbol>ATRK</Symbol>
<Symbol>OIIM</Symbol>
<Symbol>CTAC</Symbol>
<Symbol>FLWS</Symbol>
<Symbol>ATTY</Symbol>
<Symbol>FCCY</Symbol>
<Symbol>SRCE</Symbol>
<Symbol>TFSM</Symbol>
<Symbol>COMS</Symbol>
<Symbol>TDSC</Symbol>
<Symbol>ATRK</Symbol>
<Symbol>OIIM</Symbol>
<Symbol>CTAC</Symbol>
<Symbol>FLWS</Symbol>
<Symbol>ATTY</Symbol>
<Symbol>FCCY</Symbol>
<Symbol>SRCE</Symbol>
<Symbol>TFSM</Symbol>
<Symbol>COMS</Symbol>
<Symbol>TDSC</Symbol>
<Symbol>ATRK</Symbol>
<Symbol>OIIM</Symbol>
<Symbol>CTAC</Symbol>
<Symbol>FLWS</Symbol>
<Symbol>ATTY</Symbol>
<Symbol>FCCY</Symbol>
<Symbol>SRCE</Symbol>
<Symbol>TFSM</Symbol>
<Symbol>COMS</Symbol>
<Symbol>TDSC</Symbol>
<Symbol>ATRK</Symbol>
<Symbol>OIIM</Symbol>
<Symbol>CTAC</Symbol>
<Symbol>FLWS</Symbol>
<Symbol>ATTY</Symbol>
<Symbol>FCCY</Symbol>
<Symbol>SRCE</Symbol>
<Symbol>TFSM</Symbol>
<Symbol>COMS</Symbol>
<Symbol>TDSC</Symbol>
<Symbol>ATRK</Symbol>
<Symbol>OIIM</Symbol>
<Symbol>CTAC</Symbol>
<Symbol>FLWS</Symbol>
<Symbol>ATTY</Symbol>
<Symbol>FCCY</Symbol>
<Symbol>SRCE</Symbol>
<Symbol>TFSM</Symbol>
<Symbol>COMS</Symbol>
<Symbol>TDSC</Symbol>
<Symbol>ATRK</Symbol>
<Symbol>OIIM</Symbol>
<Symbol>CTAC</Symbol>
<Symbol>FLWS</Symbol>
<Symbol>ATTY</Symbol>
<Symbol>FCCY</Symbol>
<Symbol>SRCE</Symbol>
<Symbol>TFSM</Symbol>
<Symbol>COMS</Symbol>
10 times the expected result. But it makes sense since I have 10 rows, I get the xquery result for each row. Is there way to get it only once??
I translated the xquery into sql using extract (extractValue):
Select extract(object_value, '/Security/Symbol')
From security
And I'm getting the expected result: only one time the above result. But I don't want to translate all of my xqueries.
thx in advance!!
Similar Messages
-
ORA-00911:invalid character when loading an XML doc to the XMLType column
We have followed this code snippet: http://www.oracle.com/technology/sample_code/tech/java/codesnippet/xmldb/Example_Code.html#createclob
using the CLOB object to load an XML Document which has more 4000 characters to the XMLType column, we got the error -- ORA-00911:invalid character.
Sound likes an encoding issue? any suggestions would be appreciated.
BTW, we're able to use the TopLink's mapping -- Direct-to-Field to insert an XML String (<4000 characters) to the XMLType column.
Thanks!Try removing the semi-colon at the end of your statement. That is the cause of ORA-911 with DBMS_SQL.PARSE and EXECUTE IMMEDIATE, I don't see why ADO should be any different.
Cheers, APC -
How can i delete an element in a XMLTYPE-Column?
Hi!
I have the following xml-doc in an xmltype-column:
<root>
[...a lot of different elements...]
<a_element type="a">[...]</a_element>
<a_element type="b">[...]</a_element>
[...a lot of different elements...]
</root>
Now I want to "delete" all a_elements with type=b in the xml-output. I thought i could do it with the updateXML-Function. But i don't know how. Changing values and sub-Elements works, but not deleting them?
Does anybody know, how i could do it?
Bye,
JensI think You need to update the parent-node, You make changes to the parent when You detach the elements of concern.
Hope this helps
Marcel -
Oracle XQuery performance issue in XMLType column
Dear All,
As for oracle I'm using oracle 11g to measure the performance.
I'm using data from XMark project which is a >100MB data of XML for bencmarking purposes.
I make a table that contains an XMLType column and upload the data into that column, after doing that I try to do a query like this:
select xmlquery(
'for $i in /site/people/person
where $i/id = "person0"
return $i/name'
passing BookXMLContent Returning Content)
from Book;
The purpose of this query is to retrieve the name of a person that have id = 'person0'
My questions are:
1. Did I do something wrong with my query?
2. Is there any setting on the database that I should done prior to doing the query to done significantly better result?
3. Is there any other approach that are much better than I currently used?
Regards,
Anthony Steven
Edited by: mdrake on Nov 4, 2009 6:01 AMAnthony
First, please read the licencing terms for Oracle ( And I suspect DB2, MSFT) . You are not allowed to publish externally (in any form, including forum posts :) ) the results of any benchmarking activities. I have edited your post accordingly. I hope this research is not part of a thesis or similar work that would intend making public as you and your institution would be in violation of your licence agreeement were you to do so.
Now back to your question, how can you improve performance for XMark
#1. Can you show us the create table statement you used, so we can see how you created your XMLType column BOOKXMLCONTENT.
#2. Did you create any indexes
#3. Did you look at the explain plan output.
-Mark
Edited by: mdrake on Nov 4, 2009 6:06 AM -
Correct way to handle updates of XMLtype columns in standard tables.
Hello to whoever may read this,
I am currently studying the XML functionality of oracle DB for a uni project.
We have been asked to compare/contrast solutions to publishing product and price data for data stored in standard relational tables, and data stored in XML type tables. For extra marks, i am looking at a table containing an XMLType column for multiple items of data relating to the primarykey.
I have managed to get my head around publishing the data - pretty straight forward, but we have also been asked to show how we can update data, which isn't a problem within the standard tables/columns, but when it comes to the XMLType columns/tables, i dont have a clue.
At the moment i am working on trying to update an XMLtype column. The table itself is a "product" table, and contains product information, as well as an XMLType column containing multiple changes to the prices. In the relational tables, this "product" table has a one-to-many link to another table called price_history which contains details about past prices (which is populated by a trigger on update/insert of a new price). But in this table all the product changes are stored in XML format in the XML type column "prices".
Table columns: id number(4), name varchar2(25), prices xmltype;
example data: 1781, CDW 20/48/E, <product_prices><price_change>
<change_id>1</change_id>
<date_changed>2009-10-13</date_changed>
<details>price increased</details>
<new_value>234</new_value>
</price_change>
<price_change>
<change_id>2</change_id>
<date_changed>2009-10-13</date_changed>
<details>price increased</details>
<new_value>235</new_value>
</price_change></product_prices>
We need to give examples of an update. I have been looking around the net, and these forums for a solution now for about 4 hours. My own thoughts are that to update this with a new price change i need to, SELECT the current data INTO a variable, then concatenate that variable with the new price change info e.g.
<price_change>
<change_id>3</change_id>
<date_changed>2009-10-13</date_changed>
<details>price decreased</details>
<new_value>230</new_value>
</price_change>
then insert that whole chunk of data again to overwrite the old data.
Now im fairly certain there is some function somewhere which will allow me to do this update/insert operation without going through this process... After i am done with this update of XMLType column data, i need to tackle updating data in an XMLType Table with XQuery(? apparently), so if you have any pointers for that please let me know.
Could one of you experts point me in the right direction for this? Any advice at this stage is a great help and will stop me losing my mind.
p.s. im sorry about the lengthy description of the problem/solution required. How to describle something i dont understand? I ask myself.Hi,
You really need to take a look at the XMLDB Developers guide.
For updating XML with SQL/XML see UPDATEXML and for XQuery see [Using XQuery with Oracle XMLDB|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb_xquery.htm#sthref1673]
HTH,
Chris -
NOT ABLE TO RECLAIM STORAGE USED BY XMLTYPE COLUMN
Since we are on Oracle 9i, the 10G solution DBMS_XMLSCHEMA.CopyEvolve() is not available, we are trying to do it by ourselves.
see the doc,
Re: how to make xml schema change when there are existing records in the ta
However, our requirement is different in the following ways:
1. We hope to be able to add/drop as many XMLTYPE columns to a table as we
want( all structured storage, but with different schemas).
2. When a XMLTYPE Schema needs to be updated, we will add a new
xmltype column, assign it the new schema and migrate the data from the old column. After that we want to drop the old xmltype column and it's schema to reclaim all the storage.
The underlying xml tables are drop, space reclaimed.
However, we found out that the segment/blocks/bytes of the xmltype column itself is not released.
Question:
1. Since Xmltype column associated with xmltype schema is structured
stored, the xmldoc should parsed and stored in underlying tables. However, it seems that the xmltype column itself is acquiring sunstantial amount of space.
By querying user_segments table, we saw the underlying structure is actually taking constant and small space, however, the main table is taking huge space.(We populated the table with 61K rows), For instance,
SEGMENT_NAME BYTES SEGMENT_TYPE
PERFORMANCEEVENT 260046848 TABLE
SYS_C007080275 1048576 INDEX
Performance1833_TAB 65536 TABLE
Date1831_TAB 65536 TABLE
LocationAddress1814_TAB 65536 TABLE
SYS_IL0010401244C00018$$ 65536 LOBINDEX
SYS_IL0010401244C00012$$ 65536 LOBINDEX
Where PERFORMANCEEVENT is the main table.
Why?Try to read this post.
This will give you an idea about the way and when xml is shred into tables.
XMLType column based on XML Schema: several questions
In your case since you are not using the default table, the data is stored witin the table itself as oracle has not shred the data. -
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. -
Insert performance on a table with schema based XMLType column
Hi,
We are inserting around 500K rows into a table which has one XMLType column (schema based). Schema is simple and the size of the XMLType column is also not very large (on an average only around 100 bytes (max might be around 1k-2k), but it takes around 1 hr for every 20K rows, which seems very slow.
The schema is like this :
<schema targetNamespace="http://www.citadon.com/xml/test.xsd"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb"
xdb:storeVarrayAsTable="true"
version="1.0" elementFormDefault="qualified">
<element name="cas">
<complexType>
<sequence>
<element name="ca" minOccurs="0" maxOccurs="unbounded">
<complexType>
<sequence>
<element name="id" type="string"/>
<element name="value" type="string"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>
Any thoughts on how to improve performance?
-SriniYou need to have sufficient data.. Also the event show in the following code may help depending on the nature of the query....
Note in the PurchaseOrder Example if I only have 133 docs, instead of 10,000 I will get tablescan and index full scans
C:\oracle\xdb\bugs\xdbBasicDemo>sqlplus /nolog @testcase XDBTEST XDBTEST
SQL*Plus: Release 10.1.0.3.0 - Production on Fri Aug 27 22:57:36 2004
Copyright (c) 1982, 2004, 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 10000
SQL> set feedback on
SQL> set lines 132
SQL> set pages 50
SQL> --
SQL> drop index iPartNumberIndex
2 /
Index dropped.
Elapsed: 00:00:02.25
SQL> alter index LINEITEM_LIST rebuild
2 /
Index altered.
Elapsed: 00:00:02.15
SQL> desc PURCHASEORDER
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "http://localhost:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd" Element "Pu
ject-relational TYPE "PURCHASEORDER_T"
SQL> --
SQL> col level format 99999
SQL> col parent_table_column format A32
SQL> col table_name format A32
SQL> col table_type_name format A32
SQL> --
SQL> select level, PARENT_TABLE_COLUMN, TABLE_TYPE_NAME, TABLE_NAME
2 from USER_NESTED_TABLES
3 connect by PRIOR TABLE_NAME = PARENT_TABLE_NAME
4 start with PARENT_TABLE_NAME = 'PURCHASEORDER'
5 /
LEVEL PARENT_TABLE_COLUMN TABLE_TYPE_NAME TABLE_NAME
1 "XMLDATA"."ACTIONS"."ACTION" ACTION_V ACTION_TABLE
1 "XMLDATA"."LINEITEMS"."LINEITEM" LINEITEM_V LINEITEM_TABLE
2 rows selected.
Elapsed: 00:00:13.60
SQL> desc LINEITEM_T
LINEITEM_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
ITEMNUMBER NUMBER(38)
DESCRIPTION VARCHAR2(256 CHAR)
PART PART_T
SQL> --
SQL> desc PART_T
PART_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
PART_NUMBER VARCHAR2(14 CHAR)
QUANTITY NUMBER(12,2)
UNITPRICE NUMBER(8,4)
SQL> --
SQL> select count(*)
2 from purchaseorder
3 /
COUNT(*)
10000
1 row selected.
Elapsed: 00:00:05.31
SQL> select count(*)
2 from purchaseorder,
3 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
4 /
COUNT(*)
148814
1 row selected.
Elapsed: 00:09:40.54
SQL> create index iPartNumberIndex
2 on LINEITEM_TABLE l
3 ( l.PART.PART_NUMBER,NESTED_TABLE_ID)
4 /
Index created.
Elapsed: 00:00:36.11
SQL> explain plan for
2 select count(*)
3 from purchaseorder
4 where existsNode(object_value,'/PurchaseOrder/LineItems/LineItem[Part/@Id="717951002372"]') = 1
5 /
Explained.
Elapsed: 00:00:01.14
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 2571550067
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 116 | 93 (2)| 00:00:02 |
| 1 | SORT AGGREGATE | | 1 | 116 | | |
| 2 | NESTED LOOPS | | 25 | 2900 | 93 (2)| 00:00:02 |
| 3 | SORT UNIQUE | | 25 | 1675 | 79 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | LINEITEM_DATA | 25 | 1675 | 79 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | | 3 (0)| 00:00:01 |
|* 6 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 49 | 1 (0)| 00:00:01 |
|* 7 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - access("SYS_NC00011$"='717951002372')
5 - access("SYS_NC00011$"='717951002372')
6 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-in
stance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-propert
ies/><read-contents/></privilege>''))=1)
7 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
26 rows selected.
Elapsed: 00:00:03.12
SQL> select count(*)
2 from purchaseorder
3 where existsNode(object_value,'/PurchaseOrder/LineItems/LineItem[Part/@Id="717951002372"]') = 1
4 /
COUNT(*)
33
1 row selected.
Elapsed: 00:00:04.63
SQL> select count(*)
2 from purchaseorder,
3 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
4 where existsNode(value(l),'/LineItem[Part/@Id="717951002372"]') = 1
5 /
COUNT(*)
33
1 row selected.
Elapsed: 00:00:00.32
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 2571550067
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 116 | 93 (2)| 00:00:02 |
| 1 | SORT AGGREGATE | | 1 | 116 | | |
| 2 | NESTED LOOPS | | 25 | 2900 | 93 (2)| 00:00:02 |
| 3 | SORT UNIQUE | | 25 | 1675 | 79 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | LINEITEM_DATA | 25 | 1675 | 79 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | | 3 (0)| 00:00:01 |
|* 6 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 49 | 1 (0)| 00:00:01 |
|* 7 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - access("SYS_NC00011$"='717951002372')
5 - access("SYS_NC00011$"='717951002372')
6 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-in
stance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-propert
ies/><read-contents/></privilege>''))=1)
7 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
26 rows selected.
Elapsed: 00:00:00.04
SQL> explain plan for
2 select extractValue(object_value,'/PurchaseOrder/Reference')
3 from purchaseorder,
4 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
5 where existsNode(value(l),'/LineItem[Part/@Id="717951002372"]') = 1
6 /
Explained.
Elapsed: 00:00:00.07
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 713363872
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 25 | 8000 | 104 (0)| 00:00:02 |
| 1 | NESTED LOOPS | | 25 | 8000 | 104 (0)| 00:00:02 |
|* 2 | INDEX UNIQUE SCAN | LINEITEM_DATA | 25 | 1675 | 79 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | | 3 (0)| 00:00:01 |
|* 4 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 253 | 1 (0)| 00:00:01 |
|* 5 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("SYS_NC00011$"='717951002372')
3 - access("SYS_NC00011$"='717951002372')
4 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-i
nstance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-proper
ties/><read-contents/></privilege>''))=1)
5 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
24 rows selected.
Elapsed: 00:00:00.04
SQL> select extractValue(object_value,'/PurchaseOrder/Reference')
2 from purchaseorder,
3 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
4 where existsNode(value(l),'/LineItem[Part/@Id="717951002372"]') = 1
5 /
EXTRACTVALUE(OBJECT_VALUE,'/PU
MWEISS-20030616154327385GMT
NSARCHAN-20030703170041824GMT
HBAER-20030206173836987GMT
LOZER-20031110131149107GMT
WTAYLOR-20030120174534374GMT
MHARTSTE-20031103172937613GMT
KGEE-20030919215826550GMT
PSULLY-20030712141634504GMT
JPATEL-20030630175356693GMT
RMATOS-2003072920455000GMT
DRAPHEAL-20030528180033254GMT
JRUSSEL-20031121213026539GMT
PTUCKER-20030918160532301GMT
SVOLLMAN-20031027120838903GMT
WGIETZ-20030208185026303GMT
TFOX-20030110164614994GMT
JPATEL-20030304214301386GMT
GGEONI-20030606135257846GMT
STOBIAS-20030817120358785GMT
COLSEN-20030525200717658GMT
SBAIDA-20030224182546606GMT
IMIKKILI-20030118180347537GMT
ABULL-20030429162730766GMT
NSARCHAN-20031113183134873GMT
LBISSOT-20030809134114505GMT
JKING-20030420162058859GMT
JMALLIN-20030506152048261GMT
AFRIPP-20030311153808601GMT
SHIGGINS-20030831151756257GMT
DBERNSTE-20030626122725631GMT
KPARTNER-20031021160248962GMT
ABANDA-2003062721524842GMT
DOCONNEL-20030904214708637GMT
33 rows selected.
Elapsed: 00:00:00.07
SQL> explain plan for
2 select extractValue(object_value,'/PurchaseOrder/Reference')
3 from purchaseorder
4 where existsNode
5 (
6 object_value,
7 '/PurchaseOrder/LineItems/LineItem/Part[@Id="717951002372"]'
8 ) = 1
9 /
Explained.
Elapsed: 00:00:00.02
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 849879259
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 25 | 8000 | 93 (2)| 00:00:02 |
| 1 | NESTED LOOPS | | 25 | 8000 | 93 (2)| 00:00:02 |
| 2 | SORT UNIQUE | | 25 | 1675 | 79 (0)| 00:00:01 |
|* 3 | INDEX UNIQUE SCAN | LINEITEM_DATA | 25 | 1675 | 79 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | | 3 (0)| 00:00:01 |
|* 5 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 253 | 1 (0)| 00:00:01 |
|* 6 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - access("SYS_NC00011$"='717951002372')
4 - access("SYS_NC00011$"='717951002372')
5 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-i
nstance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-proper
ties/><read-contents/></privilege>''))=1)
6 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
25 rows selected.
Elapsed: 00:00:00.03
SQL> select extractValue(object_value,'/PurchaseOrder/Reference')
2 from purchaseorder
3 where existsNode
4 (
5 object_value,
6 '/PurchaseOrder/LineItems/LineItem/Part[@Id="717951002372"]'
7 ) = 1
8 /
EXTRACTVALUE(OBJECT_VALUE,'/PU
MWEISS-20030616154327385GMT
NSARCHAN-20030703170041824GMT
HBAER-20030206173836987GMT
LOZER-20031110131149107GMT
WTAYLOR-20030120174534374GMT
MHARTSTE-20031103172937613GMT
KGEE-20030919215826550GMT
PSULLY-20030712141634504GMT
JPATEL-20030630175356693GMT
RMATOS-2003072920455000GMT
DRAPHEAL-20030528180033254GMT
JRUSSEL-20031121213026539GMT
PTUCKER-20030918160532301GMT
SVOLLMAN-20031027120838903GMT
WGIETZ-20030208185026303GMT
TFOX-20030110164614994GMT
JPATEL-20030304214301386GMT
GGEONI-20030606135257846GMT
STOBIAS-20030817120358785GMT
COLSEN-20030525200717658GMT
SBAIDA-20030224182546606GMT
IMIKKILI-20030118180347537GMT
ABULL-20030429162730766GMT
NSARCHAN-20031113183134873GMT
LBISSOT-20030809134114505GMT
JKING-20030420162058859GMT
JMALLIN-20030506152048261GMT
AFRIPP-20030311153808601GMT
SHIGGINS-20030831151756257GMT
DBERNSTE-20030626122725631GMT
KPARTNER-20031021160248962GMT
ABANDA-2003062721524842GMT
DOCONNEL-20030904214708637GMT
33 rows selected.
Elapsed: 00:00:00.04
SQL> alter session set events ='19027 trace name context forever, level 0x800000'
2 /
Session altered.
Elapsed: 00:00:00.00
SQL> explain plan for
2 select count(*)
3 from purchaseorder
4 where existsNode(object_value,'/PurchaseOrder/LineItems/LineItem[Part/@Id="717951002372"]') = 1
5 /
Explained.
Elapsed: 00:00:00.03
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 3049344732
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 69 | 17 (6)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 69 | | |
| 2 | NESTED LOOPS | | 25 | 1725 | 17 (6)| 00:00:01 |
| 3 | SORT UNIQUE | | 25 | 750 | 3 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | 750 | 3 (0)| 00:00:01 |
|* 5 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 39 | 1 (0)| 00:00:01 |
|* 6 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - access("SYS_NC00011$"='717951002372')
5 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-in
stance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-propert
ies/><read-contents/></privilege>''))=1)
6 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
24 rows selected.
Elapsed: 00:00:00.03
SQL> select count(*)
2 from purchaseorder
3 where existsNode(object_value,'/PurchaseOrder/LineItems/LineItem[Part/@Id="717951002372"]') = 1
4 /
COUNT(*)
33
1 row selected.
Elapsed: 00:00:00.01
SQL> select count(*)
2 from purchaseorder,
3 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
4 where existsNode(value(l),'/LineItem[Part/@Id="717951002372"]') = 1
5 /
COUNT(*)
33
1 row selected.
Elapsed: 00:00:00.01
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 3049344732
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 69 | 17 (6)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 69 | | |
| 2 | NESTED LOOPS | | 25 | 1725 | 17 (6)| 00:00:01 |
| 3 | SORT UNIQUE | | 25 | 750 | 3 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | 750 | 3 (0)| 00:00:01 |
|* 5 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 39 | 1 (0)| 00:00:01 |
|* 6 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - access("SYS_NC00011$"='717951002372')
5 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-in
stance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-propert
ies/><read-contents/></privilege>''))=1)
6 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
24 rows selected.
Elapsed: 00:00:00.03
SQL> explain plan for
2 select extractValue(object_value,'/PurchaseOrder/Reference')
3 from purchaseorder,
4 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
5 where existsNode(value(l),'/LineItem[Part/@Id="717951002372"]') = 1
6 /
Explained.
Elapsed: 00:00:00.06
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 1516269755
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 25 | 2450 | 28 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 25 | 2450 | 28 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | 750 | 3 (0)| 00:00:01 |
|* 3 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 68 | 1 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("SYS_NC00011$"='717951002372')
3 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-i
nstance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-proper
ties/><read-contents/></privilege>''))=1)
4 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
22 rows selected.
Elapsed: 00:00:00.04
SQL> select extractValue(object_value,'/PurchaseOrder/Reference')
2 from purchaseorder,
3 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
4 where existsNode(value(l),'/LineItem[Part/@Id="717951002372"]') = 1
5 /
EXTRACTVALUE(OBJECT_VALUE,'/PU
MWEISS-20030616154327385GMT
NSARCHAN-20030703170041824GMT
HBAER-20030206173836987GMT
LOZER-20031110131149107GMT
WTAYLOR-20030120174534374GMT
MHARTSTE-20031103172937613GMT
KGEE-20030919215826550GMT
PSULLY-20030712141634504GMT
JPATEL-20030630175356693GMT
RMATOS-2003072920455000GMT
DRAPHEAL-20030528180033254GMT
JRUSSEL-20031121213026539GMT
PTUCKER-20030918160532301GMT
SVOLLMAN-20031027120838903GMT
WGIETZ-20030208185026303GMT
TFOX-20030110164614994GMT
JPATEL-20030304214301386GMT
GGEONI-20030606135257846GMT
STOBIAS-20030817120358785GMT
COLSEN-20030525200717658GMT
SBAIDA-20030224182546606GMT
IMIKKILI-20030118180347537GMT
ABULL-20030429162730766GMT
NSARCHAN-20031113183134873GMT
LBISSOT-20030809134114505GMT
JKING-20030420162058859GMT
JMALLIN-20030506152048261GMT
AFRIPP-20030311153808601GMT
SHIGGINS-20030831151756257GMT
DBERNSTE-20030626122725631GMT
KPARTNER-20031021160248962GMT
ABANDA-2003062721524842GMT
DOCONNEL-20030904214708637GMT
33 rows selected.
Elapsed: 00:00:00.01
SQL> explain plan for
2 select extractValue(object_value,'/PurchaseOrder/Reference')
3 from purchaseorder
4 where existsNode
5 (
6 object_value,
7 '/PurchaseOrder/LineItems/LineItem/Part[@Id="717951002372"]'
8 ) = 1
9 /
Explained.
Elapsed: 00:00:00.03
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 1197255270
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 25 | 2450 | 17 (6)| 00:00:01 |
| 1 | NESTED LOOPS | | 25 | 2450 | 17 (6)| 00:00:01 |
| 2 | SORT UNIQUE | | 25 | 750 | 3 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | 750 | 3 (0)| 00:00:01 |
|* 4 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 68 | 1 (0)| 00:00:01 |
|* 5 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - access("SYS_NC00011$"='717951002372')
4 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-i
nstance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-proper
ties/><read-contents/></privilege>''))=1)
5 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
23 rows selected.
Elapsed: 00:00:00.03
SQL> select extractValue(object_value,'/PurchaseOrder/Reference')
2 from purchaseorder
3 where existsNode
4 (
5 object_value,
6 '/PurchaseOrder/LineItems/LineItem/Part[@Id="717951002372"]'
7 ) = 1
8 /
EXTRACTVALUE(OBJECT_VALUE,'/PU
MWEISS-20030616154327385GMT
NSARCHAN-20030703170041824GMT
HBAER-20030206173836987GMT
LOZER-20031110131149107GMT
WTAYLOR-20030120174534374GMT
MHARTSTE-20031103172937613GMT
KGEE-20030919215826550GMT
PSULLY-20030712141634504GMT
JPATEL-20030630175356693GMT
RMATOS-2003072920455000GMT
DRAPHEAL-20030528180033254GMT
JRUSSEL-20031121213026539GMT
PTUCKER-20030918160532301GMT
SVOLLMAN-20031027120838903GMT
WGIETZ-20030208185026303GMT
TFOX-20030110164614994GMT
JPATEL-20030304214301386GMT
GGEONI-20030606135257846GMT
STOBIAS-20030817120358785GMT
COLSEN-20030525200717658GMT
SBAIDA-20030224182546606GMT
IMIKKILI-20030118180347537GMT
ABULL-20030429162730766GMT
NSARCHAN-20031113183134873GMT
LBISSOT-20030809134114505GMT
JKING-20030420162058859GMT
JMALLIN-20030506152048261GMT
AFRIPP-20030311153808601GMT
SHIGGINS-20030831151756257GMT
DBERNSTE-20030626122725631GMT
KPARTNER-20031021160248962GMT
ABANDA-2003062721524842GMT
DOCONNEL-20030904214708637GMT
33 rows selected.
Elapsed: 00:00:00.03
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options -
Problem deleting from table with xmltype column
Hi,
Using a standard, simple screen (generated from JHeadstart), I don't seem to be able to delete from a table including an xmltype column. I have tried it even with a very simple mock table with only one column, an xmltype column, and every time I check the "delete" box and click "save", I get the following error:
oracle.jbo.RowInconsistentException: JBO-25014: Another user has changed the row with primary key oracle.jbo.Key[33 ].
I have tried this in the JDeveloper application module tester too and the result is the same.
Is it possible to delete a row from a table with an xmltype column? Am I doing something wrong? Is there something special needs done?
As I say, I did this with a one-xmltype-column table using the "Business Components from Tables" wizard, accepting all the defaults.
Thanks,
DarrenIn short you want
SELECT extractvalue(myxml, '/PurchaseOrder/Reference')
FROM dab_test;This difference is that for dab_xml, there are no columns defined for the table, therefore you are [OBJECT_VALUE|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/pseudocolumns006.htm#sthref830] as an alias for a non existent column.
With dab_test, you have a column that contains the XML so you need to use that column name instead of OBJECT_VALUE. -
Difference between an XMLType table and a table with an XMLType column?
Hi all,
Still trying to get my mind around all this XML stuff.
Can someone concisely explain the difference between:
create table this_is_xmltype_tab of xmltype;and
create table this_is_tab_w_xmltpe_col(id number, document xmltype);What are the relative advantages and disadvantages of each approach? How do they really differ?
Thanks,
-MarkThere is another pointer Mark, that I realized when I was thinking about the differences...
If you would look up in the manual regarding "xdb:annotations" you would learn about a method using an XML Schema to generate out of the box your whole design in terms of physical layout and/or design principles. In my mind this should be the preferred solution if you are dealing with very complex XML Schema environments. Taking your XML Schema as your single point design layout, that during the actual implementation automatically generates and builds all your needed database objects and its physical requirements, has great advantages in points of design version management etc., but...
...it will create automatically an XMLType table (based on OR, Binary XML of "hybrid" storage principles, aka the ones that are XML Schema driven) and not AFAIK a XMLtype column structure: so as in "our" case a table with a id column and a xmltype column.
In principle you could relationally relate to this as:
+"I have created an EER diagram and a Physical diagram, I mix the content/info of those two into one diagram." "Then I _+execute+_ it in the database and the end result will be an database user/schema that has all the xxxx amount of physical objects I need, the way I want it to be...".+
...but it will be in the form of an XMLType table structure...
xdb:annotations can be used to create things like:
- enforce database/company naming conventions
- DOM validation enabled or not
- automatic IOT or BTree index creation (for instance in OR XMLType storage)
- sort search order enforced or not
- default tablenames and owners
- extra column or table property settings like for partitioning XML data
- database encoding/mapping used for SQL and binary storage
- avoid automatic creation of Oracle objects (tables/types/etc), for instance, via xdb:defaultTable="" annotations
- etc...
See here for more info: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10492/xdb05sto.htm#ADXDB4519
and / or for more detailed info:
http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10492/xdb05sto.htm#i1030452
http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10492/xdb05sto.htm#i1030995
http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10492/xdb05sto.htm#CHDCEBAG
... -
Help on how to query 11g table with XMLType column
To all,
We have this table:
DESC MESSAGE
Name Null Type
MESSAGE_ID NOT NULL NUMBER(38)
REQUEST_UU_ID NOT NULL VARCHAR2(50)
MESSAGE_TYPE_CD NOT NULL CHAR(3 CHAR)
EMPLOYEE_NUM NOT NULL VARCHAR2(8)
SEQUENCE_NUM VARCHAR2(20)
REVERSAL_SEQUENCE_NUM VARCHAR2(20)
TRANSACTION_TS TIMESTAMP(6)
MESSAGE_CONTENT_TXT NOT NULL XMLTYPE()
CREATE_BY_NM NOT NULL VARCHAR2(50 CHAR)
CREATE_BY_TS NOT NULL TIMESTAMP(6)
LAST_UPDATE_BY_NM NOT NULL VARCHAR2(50 CHAR)
LAST_UPDATE_BY_TS NOT NULL TIMESTAMP(6)
Given we have multiple columns and one is XMLType how do I query to find rows in the db that match this XPath
Here is a fragment of XML that is held in MESSAGE_CONTENT_TXT XMLType column:
<?xml version="1.0" encoding="UTF-8"?>
<cfg-env:Envelope xmlns="http://www.co.com/schemas/CFX/" xmlns:cfg-env="http://www.co.com/schemas/cfg-env/" xmlns:cfg-hdr="http://www.co.com/schemas/cfg-hdr/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.co.com/schemas/cfg-env/" >
<cfg-env:Header>
<cfg-hdr:MessageHeader xmlns:cfg-hdr="http://www.co.com/schemas/cfg-hdr/" xmlns:cfg-env="http://www.co.com/schemas/cfg-env/" xmlns="http://www.co.com/schemas/CFX/">
<cfg-hdr:Service>
<cfg-hdr:ServiceName>process</cfg-hdr:ServiceName>
<cfg-hdr:MessageType>Request</cfg-hdr:MessageType>
<cfg-hdr:ServiceVersion>1</cfg-hdr:ServiceVersion>
</cfg-hdr:Service>
<cfg-hdr:From>
<cfg-hdr:PartyId>13-175-8724</cfg-hdr:PartyId>
<cfg-hdr:CostCenter>2009065</cfg-hdr:CostCenter>
<cfg-hdr:System>
<cfg-hdr:Application>[email protected]</cfg-hdr:Application>
<cfg-hdr:Version>1.0</cfg-hdr:Version>
<cfg-hdr:Channel>TLR</cfg-hdr:Channel>
</cfg-hdr:System>
<cfg-hdr:OrigReplyToQMgr>QMBKRD01</cfg-hdr:OrigReplyToQMgr>
<cfg-hdr:OrigReplyToQ>Q1</cfg-hdr:OrigReplyToQ>
</cfg-hdr:From>
<cfg-hdr:UserSession>
<cfg-hdr:SignonRole>User</cfg-hdr:SignonRole>
<cfg-hdr:LogonId>R099999</cfg-hdr:LogonId>
I'm trying to find rows in the database that are /Envelope/Header/MessageHeader/UserSession/LogonId/R099999.
Thanks for the assistance. I'm new to XML DB. I appreciate the help.
EricHi Eric,
You can use XMLExists, like this :
select *
from message t
where xmlexists(
     'declare namespace env = "http://www.co.com/schemas/cfg-env/"; (: :)
      declare namespace hdr = "http://www.co.com/schemas/cfg-hdr/"; (: :)
      /env:Envelope/env:Header/hdr:MessageHeader/hdr:UserSession[hdr:LogonId=$id]'
      passing t.message_content_txt
            , 'R099999' as "id"
); -
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... -
ORA-07445 in the alert log when inserting into table with XMLType column
I'm trying to insert an xml-document into a table with a schema-based XMLType column. When I try to insert a row (using plsql-developer) - oracle is busy for a few seconds and then the connection to oracle is lost.
Below you''ll find the following to recreate the problem:
a) contents from the alert log
b) create script for the table
c) the before-insert trigger
d) the xml-schema
e) code for registering the schema
f) the test program
g) platform information
Alert Log:
Fri Aug 17 00:44:11 2007
Errors in file /oracle/app/oracle/product/10.2.0/db_1/admin/dntspilot2/udump/dntspilot2_ora_13807.trc:
ORA-07445: exception encountered: core dump [SIGSEGV] [Address not mapped to object] [475177] [] [] []
Create script for the table:
CREATE TABLE "DNTSB"."SIGNATURETABLE"
( "XML_DOCUMENT" "SYS"."XMLTYPE" ,
"TS" TIMESTAMP (6) WITH TIME ZONE NOT NULL ENABLE
) XMLTYPE COLUMN "XML_DOCUMENT" XMLSCHEMA "http://www.sporfori.fo/schemas/www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd" ELEMENT "Object"
ROWDEPENDENCIES ;
Before-insert trigger:
create or replace trigger BIS_SIGNATURETABLE
before insert on signaturetable
for each row
declare
-- local variables here
l_sigtab_rec signaturetable%rowtype;
begin
if (:new.xml_document is not null) then
:new.xml_document.schemavalidate();
end if;
l_sigtab_rec.xml_document := :new.xml_document;
end BIS_SIGNATURETABLE2;
XML-Schema (xmldsig-core-schema.xsd):
=====================================================================================
<?xml version="1.0" encoding="utf-8"?>
<!-- Schema for XML Signatures
http://www.w3.org/2000/09/xmldsig#
$Revision: 1.1 $ on $Date: 2002/02/08 20:32:26 $ by $Author: reagle $
Copyright 2001 The Internet Society and W3C (Massachusetts Institute
of Technology, Institut National de Recherche en Informatique et en
Automatique, Keio University). All Rights Reserved.
http://www.w3.org/Consortium/Legal/
This document is governed by the W3C Software License [1] as described
in the FAQ [2].
[1] http://www.w3.org/Consortium/Legal/copyright-software-19980720
[2] http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xdb="http://xmlns.oracle.com/xdb"
targetNamespace="http://www.w3.org/2000/09/xmldsig#" version="0.1" elementFormDefault="qualified">
<!-- Basic Types Defined for Signatures -->
<xs:simpleType name="CryptoBinary">
<xs:restriction base="xs:base64Binary">
</xs:restriction>
</xs:simpleType>
<!-- Start Signature -->
<xs:element name="Signature" type="ds:SignatureType"/>
<xs:complexType name="SignatureType">
<xs:sequence>
<xs:element ref="ds:SignedInfo"/>
<xs:element ref="ds:SignatureValue"/>
<xs:element ref="ds:KeyInfo" minOccurs="0"/>
<xs:element ref="ds:Object" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:ID" use="optional"/>
</xs:complexType>
<xs:element name="SignatureValue" type="ds:SignatureValueType"/>
<xs:complexType name="SignatureValueType">
<xs:simpleContent>
<xs:extension base="xs:base64Binary">
<xs:attribute name="Id" type="xs:ID" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- Start SignedInfo -->
<xs:element name="SignedInfo" type="ds:SignedInfoType"/>
<xs:complexType name="SignedInfoType">
<xs:sequence>
<xs:element ref="ds:CanonicalizationMethod"/>
<xs:element ref="ds:SignatureMethod"/>
<xs:element ref="ds:Reference" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:ID" use="optional"/>
</xs:complexType>
<xs:element name="CanonicalizationMethod" type="ds:CanonicalizationMethodType"/>
<xs:complexType name="CanonicalizationMethodType" mixed="true">
<xs:sequence>
<xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
<!-- (0,unbounded) elements from (1,1) namespace -->
</xs:sequence>
<xs:attribute name="Algorithm" type="xs:anyURI" use="required"/>
</xs:complexType>
<xs:element name="SignatureMethod" type="ds:SignatureMethodType"/>
<xs:complexType name="SignatureMethodType" mixed="true">
<xs:sequence>
<xs:element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>
<xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
<!-- (0,unbounded) elements from (1,1) external namespace -->
</xs:sequence>
<xs:attribute name="Algorithm" type="xs:anyURI" use="required"/>
</xs:complexType>
<!-- Start Reference -->
<xs:element name="Reference" type="ds:ReferenceType"/>
<xs:complexType name="ReferenceType">
<xs:sequence>
<xs:element ref="ds:Transforms" minOccurs="0"/>
<xs:element ref="ds:DigestMethod"/>
<xs:element ref="ds:DigestValue"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:ID" use="optional"/>
<xs:attribute name="URI" type="xs:anyURI" use="optional"/>
<xs:attribute name="Type" type="xs:anyURI" use="optional"/>
</xs:complexType>
<xs:element name="Transforms" type="ds:TransformsType"/>
<xs:complexType name="TransformsType">
<xs:sequence>
<xs:element ref="ds:Transform" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Transform" type="ds:TransformType"/>
<xs:complexType name="TransformType" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:any namespace="##other" processContents="lax"/>
<!-- (1,1) elements from (0,unbounded) namespaces -->
<xs:element name="XPath" type="xs:string"/>
</xs:choice>
<xs:attribute name="Algorithm" type="xs:anyURI" use="required"/>
</xs:complexType>
<!-- End Reference -->
<xs:element name="DigestMethod" type="ds:DigestMethodType"/>
<xs:complexType name="DigestMethodType" mixed="true">
<xs:sequence>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="Algorithm" type="xs:anyURI" use="required"/>
</xs:complexType>
<xs:element name="DigestValue" type="ds:DigestValueType"/>
<xs:simpleType name="DigestValueType">
<xs:restriction base="xs:base64Binary"/>
</xs:simpleType>
<!-- End SignedInfo -->
<!-- Start KeyInfo -->
<xs:element name="KeyInfo" type="ds:KeyInfoType"/>
<xs:complexType name="KeyInfoType" mixed="true">
<xs:choice maxOccurs="unbounded">
<xs:element ref="ds:KeyName"/>
<xs:element ref="ds:KeyValue"/>
<xs:element ref="ds:RetrievalMethod"/>
<xs:element ref="ds:X509Data"/>
<xs:element ref="ds:PGPData"/>
<xs:element ref="ds:SPKIData"/>
<xs:element ref="ds:MgmtData"/>
<xs:any processContents="lax" namespace="##other"/>
<!-- (1,1) elements from (0,unbounded) namespaces -->
</xs:choice>
<xs:attribute name="Id" type="xs:ID" use="optional"/>
</xs:complexType>
<xs:element name="KeyName" type="xs:string"/>
<xs:element name="MgmtData" type="xs:string"/>
<xs:element name="KeyValue" type="ds:KeyValueType"/>
<xs:complexType name="KeyValueType" mixed="true">
<xs:choice>
<xs:element ref="ds:DSAKeyValue"/>
<xs:element ref="ds:RSAKeyValue"/>
<xs:any namespace="##other" processContents="lax"/>
</xs:choice>
</xs:complexType>
<xs:element name="RetrievalMethod" type="ds:RetrievalMethodType"/>
<xs:complexType name="RetrievalMethodType">
<xs:sequence>
<xs:element ref="ds:Transforms" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="URI" type="xs:anyURI"/>
<xs:attribute name="Type" type="xs:anyURI" use="optional"/>
</xs:complexType>
<!-- Start X509Data -->
<xs:element name="X509Data" type="ds:X509DataType"/>
<xs:complexType name="X509DataType">
<xs:sequence maxOccurs="unbounded">
<xs:choice>
<xs:element name="X509IssuerSerial" type="ds:X509IssuerSerialType"/>
<xs:element name="X509SKI" type="xs:base64Binary"/>
<xs:element name="X509SubjectName" type="xs:string"/>
<xs:element name="X509Certificate" type="xs:base64Binary"/>
<xs:element name="X509CRL" type="xs:base64Binary"/>
<xs:any namespace="##other" processContents="lax"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
<xs:complexType name="X509IssuerSerialType">
<xs:sequence>
<xs:element name="X509IssuerName" type="xs:string"/>
<xs:element name="X509SerialNumber" type="xs:integer"/>
</xs:sequence>
</xs:complexType>
<!-- End X509Data -->
<!-- Begin PGPData -->
<xs:element name="PGPData" type="ds:PGPDataType"/>
<xs:complexType name="PGPDataType">
<xs:choice>
<xs:sequence>
<xs:element name="PGPKeyID" type="xs:base64Binary"/>
<xs:element name="PGPKeyPacket" type="xs:base64Binary" minOccurs="0"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:sequence>
<xs:element name="PGPKeyPacket" type="xs:base64Binary"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:choice>
</xs:complexType>
<!-- End PGPData -->
<!-- Begin SPKIData -->
<xs:element name="SPKIData" type="ds:SPKIDataType"/>
<xs:complexType name="SPKIDataType">
<xs:sequence maxOccurs="unbounded">
<xs:element name="SPKISexp" type="xs:base64Binary"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<!-- End SPKIData -->
<!-- End KeyInfo -->
<!-- Start Object (Manifest, SignatureProperty) -->
<xs:element name="Object" type="ds:ObjectType"/>
<xs:complexType name="ObjectType" mixed="true">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:any namespace="##any" processContents="lax"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:ID" use="optional"/>
<xs:attribute name="MimeType" type="xs:string" use="optional"/> <!-- add a grep facet -->
<xs:attribute name="Encoding" type="xs:anyURI" use="optional"/>
</xs:complexType>
<xs:element name="Manifest" type="ds:ManifestType"/>
<xs:complexType name="ManifestType">
<xs:sequence>
<xs:element ref="ds:Reference" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:ID" use="optional"/>
</xs:complexType>
<xs:element name="SignatureProperties" type="ds:SignaturePropertiesType"/>
<xs:complexType name="SignaturePropertiesType">
<xs:sequence>
<xs:element ref="ds:SignatureProperty" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:ID" use="optional"/>
</xs:complexType>
<xs:element name="SignatureProperty" type="ds:SignaturePropertyType"/>
<xs:complexType name="SignaturePropertyType" mixed="true">
<xs:choice maxOccurs="unbounded">
<xs:any namespace="##other" processContents="lax"/>
<!-- (1,1) elements from (1,unbounded) namespaces -->
</xs:choice>
<xs:attribute name="Target" type="xs:anyURI" use="required"/>
<xs:attribute name="Id" type="xs:ID" use="optional"/>
</xs:complexType>
<!-- End Object (Manifest, SignatureProperty) -->
<!-- Start Algorithm Parameters -->
<xs:simpleType name="HMACOutputLengthType">
<xs:restriction base="xs:integer"/>
</xs:simpleType>
<!-- Start KeyValue Element-types -->
<xs:element name="DSAKeyValue" type="ds:DSAKeyValueType"/>
<xs:complexType name="DSAKeyValueType">
<xs:sequence>
<xs:sequence minOccurs="0">
<xs:element name="P" type="ds:CryptoBinary"/>
<xs:element name="Q" type="ds:CryptoBinary"/>
</xs:sequence>
<xs:element name="G" type="ds:CryptoBinary" minOccurs="0"/>
<xs:element name="Y" type="ds:CryptoBinary"/>
<xs:element name="J" type="ds:CryptoBinary" minOccurs="0"/>
<xs:sequence minOccurs="0">
<xs:element name="Seed" type="ds:CryptoBinary"/>
<xs:element name="PgenCounter" type="ds:CryptoBinary"/>
</xs:sequence>
</xs:sequence>
</xs:complexType>
<xs:element name="RSAKeyValue" type="ds:RSAKeyValueType"/>
<xs:complexType name="RSAKeyValueType">
<xs:sequence>
<xs:element name="Modulus" type="ds:CryptoBinary"/>
<xs:element name="Exponent" type="ds:CryptoBinary"/>
</xs:sequence>
</xs:complexType>
<!-- End KeyValue Element-types -->
<!-- End Signature -->
</xs:schema>
===============================================================================
Code for registering the xml-schema
begin
dbms_xmlschema.deleteSchema('http://xmlns.oracle.com/xdb/schemas/DNTSB/www.sporfori.fo/schemas/www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd',
dbms_xmlschema.DELETE_CASCADE_FORCE);
end;
begin
DBMS_XMLSCHEMA.REGISTERURI(
schemaurl => 'http://www.sporfori.fo/schemas/www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd',
schemadocuri => 'http://www.sporfori.fo/schemas/www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd',
local => TRUE,
gentypes => TRUE,
genbean => FALSE,
gentables => TRUE,
force => FALSE,
owner => 'DNTSB',
options => 0);
end;
Test program
-- Created on 17-07-2006 by EEJ
declare
XML_TEXT3 CLOB := '<Object xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignatureProperties>
<SignatureProperty Target="">
<Timestamp xmlns="http://www.sporfori.fo/schemas/dnts/general/2006/11/14">2007-05-10T12:00:00-05:00</Timestamp>
</SignatureProperty>
</SignatureProperties>
</Object>';
xmldoc xmltype;
begin
xmldoc := xmltype(xml_text3);
insert into signaturetable
(xml_document, ts)
values
(xmldoc, current_timestamp);
end;
Platform information
Operating system:
-bash-3.00$ uname -a
SunOS dntsdb 5.10 Generic_125101-09 i86pc i386 i86pc
SQLPlus:
SQL*Plus: Release 10.2.0.3.0 - Production on Fri Aug 17 00:15:13 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Enter password:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning and Data Mining options
Kind Regards,
EyðunYou should report this in a service request on http://metalink.oracle.com.
It is a shame that you put all the effort here to describe your problem, but on the other hand you can now also copy & paste the question to Oracle Support.
Because you are using 10.2.0.3; I am guessing that you have a valid service contract... -
Is it possible to remove XMLSchema restriction from an XMLType column?
I have an XMLType column that is validated via some XMLSchema. Now I want to remove this restriction and make it just a generic XMLType column.
I tried bunch of alter table commands but I couldn't figure out the magic combination.
Is this possible?
Here is the actual problem. Unfortunately, we ended up both local and global schemas using the same URL. We have customers
out there with both schemas (early customers) or only global schema (new customers). Most of the tables were created before the global schema
was added. So, they are referencing the local schema. Now we want to evolve our schema, and I am trying to write a sql script to clean-up this mess.
My plan is:
if only global schema exists then (these are late customers)
- do nothing
else if both global and local schema exist then (these are early customers)
- If any table or table.column has dependency on local schema (I can find this out from user_dependencies) I am going to mark those
tables/columns as no schema validated. i.e. remove all references to local schema
- delete and purge the local schema
- modify those tables/columns and make them point to the global schema
end if
- evolve the schema (only global one is left)
Is there a better way/plan? Is there a way to modify a column definition and move its reference from local schema to global schema where
both schemas have the same URL?
Of course the main constraint is that we do not want to loose customer data. By the way, both local and global schemas are identical in terms of xsd.
I guess a more generic question would be, is it possible to change XMLSchema/Element settings of an XMLType column from X to Y, X to null, or null to X? (Of course the assumption is Y is a superset of X.)Couple of Questions ?
Which verson of the database...
Are you using the XML DB repository to provide path based access to the XML Content.
In general
1. You cannot break the associated between a table and it's schema..
So if I understand waht you want to do you will have to do something different..
Copy the data into a non schema based table (Either XMLType Store AS CLOB or XMLType store as SecureFile Binary XML).
YOu probably want to invoke the createNonSchemaBasedXML() operator when inserting the XML non schema based table.
Once all the data is copied, delete and purge the local schema, and all of it's types and tables.
Create a new table based on the Global Schema.
Copy the database back into the new table..
I know two data copies are a PITA, but I can think of no other way of doing this. The Schema Based XML representation contains references that can only be decoded by using the XML Schema that was used to encode the references. This appies to both Schema Based Binary XML and Object Relational Storage.
Maybe you are looking for
-
RFC error while activating the Form
hi all, i am trying to activate a new form or even while generating the pdf tab.this generates the pdf but with a popup 'no message though'. i get a success message of bytes transmitted ,code page 0000. but doesnot get activated. but when i execute i
-
Using a Verizon Lte phone in Europe with local SIM
I have a Verizon iPhone 4S and travel to France frequently. I am able to use my phone with a local French SIM, and it works fine. I am planning to get an iPhone 6, which will be 4G Lte. Will I be able to use that phone in France the same way I can us
-
My iPod is not showing up in the new iTunes
I just updated (regretfully) to the new update for iTunes and now there is no option to sync my ipod. this is getting really annoying. The iTunes store has no problem showing up in plain view, but I can't sync my stuff to my ipod. Can someone please
-
Hi, when i execute dswp transaction in solution manager it is not showing buttons like new,display etc (already one system maintained). reason? vinnuy.
-
10.5 wont install. Not sure why?
I have a G4 400 MHZ (im not concerned about speed) with just over 1 GB RAM, and a 120 GB HD to install it on. I am currently running 9.2.2, which can't run the install, because it is a .app, so I restart the computer and the install starts up. I choo