OracleDataReader allocation using extractvalue() on XMLType column
I am accessing an element within an XMLType column in a select statement using the extractvalue SQL function.
Select ExtractValue(column_name,'//Text') from table_name
I noticed that the RowSize for the command used to execute the select is unusually large (~24K). I have narrowed the space allocation issue down to the extractvalue() column, which is about 8k per instance of extractvalue() in the select statement. Since the fetch size if 64K, I am seeing a lot of calls to opsDacRead (DB round trips?) in the ODP.NET log, probably due to the fact that only 3 rows are being returned in each call to opsDacRead.
My question is: How does ODP.NET determine the amount of space allocated within the reader's buffer for such a column? The element I am trying to extract is defined in the xml schema as 'xs:string' and is never more than 40 characters or so.
Mark,
Thanks for the response.
Yes, I tried increasing FetchSize. Unfortunately, under heavy load, I experienced long execution/wait times within the first and last calls to opsDacRead() while walking the reader. I suspect that was due to allocation and clean-up.
However, I did find out why the buffer size was so large. If the xml schema does not contain length restrictions on string/text elements via the maxLength option, Oracle defines the underlying field in the data type created for the schema as VARCHAR2(4000).
I'm pretty sure that adding a maxLength restriction to the string element in the xml schema will reduce the size of the data type's field and in turn reduce the size of the Reader's buffer, but I haven't had a chance to test it.
Thanks again,
-Jeff
Similar Messages
-
Using extractvalue with XMLTYPE to extract multiple nodes
hi ,
I'm trying to fetch data from xml which is stored as clob in db (10g) ,
when i tried to fetch with query as below
SELECT extractvalue(XMLTYPE(xjm.X_MSG_XML), '//orderRequest/order/orderItem/alternativeIdentifer/value') uiid
FROM TABLE_X_MSG_ATTR xma, TABLE_X_JMS_MSG xjm
WHERE xma.X_MSG_ATTR2X_JMS_MSG=xjm.OBJID
AND xma.X_ATTR_NAME='MOP_ID'
AND xma.X_ATTR_VALUE in ('RJM78999')
and got **ORA-19025: EXTRACTVALUE returns value of only one node**
so i modified it as below
SELECT extractvalue(value(x), '//orderRequest/order/orderItem/alternativeIdentifer/value') uiid
FROM TABLE_X_MSG_ATTR xma, TABLE_X_JMS_MSG xjm
,TABLE(XMLSequence(extractvalue(XMLTYPE(xjm.X_MSG_XML),'//orderRequest/order/orderItem/alternativeIdentifer/value'))) x
WHERE xma.X_MSG_ATTR2X_JMS_MSG=xjm.OBJID
AND xma.X_ATTR_NAME='MOP_ID'
AND xma.X_ATTR_VALUE in ('RJM78999')
ORA-29900: operator binding does not exist
ORA-06553: PLS-306: wrong number or types of arguments in call to 'XMLSEQUENCE'
no success :( it is working for single record (node)all perfect
Thnkz
Edited by: Volution2111 on Sep 11, 2010 5:08 AM
Edited by: Volution2111 on Sep 11, 2010 5:10 AMDifficult to give the exact answer without knowing which node repeats..
Howver it will be something like this
select extractValue(value(x),'/RepeatingNode/NonRepatingNode/NonRepeatingNode)
from TABLE, table(xmlsequence(extract(xmltype(clob),'/Root/Node/RepeatingNode')))) x -
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... -
hi all,
i've recently implementing a project which need to stored hierarchical data. since relational db alone can only offer flatfile and implementing hierarchical data using realtional table with design structure such as
1. MPTT(Modified Preorder Tree Traversal)
2. Adjacency List
3. Recursion
has a lot of drawback ESPECIALLY on searching/traversing to find parent nodes. so i decided to try using oracle xmldb since xml is by nature hierarchical. so i came out with a design by using relational table + xmltype column. what i did is for eg. a customer table
create table customer(
id varchar2(32),
name varchar2(50),
balance number,
xmltype
the xmltype is stored as schema enabled not Clob. the schema is defined where the customer node will have unlimited nesting with each other.
where the xmltype column is to stored the position/path of this customers within xml tree.
eg. This customer id is 3 and the path is stored as below
<root>
<customer id="1">
<customer id="2">
<customer id="3"/>
</customer>
</customer>
</root>
the path will have a root node element and nested all the way until this customers. so in short i will be able to select this customer using Xpath, by traversing up by grabbing all the parents, getting all the child of this customer and getting the sibling as well.
the operation on this row record will involved with updating or querying(mostly) the xmltree inside this column.
so, my question is, based on this design:
1. is this design relevent? compared to just used MPTT(Modified Preorder Tree Traversal), Adjacency List & Recursion?
2. which isolation level should i use if there's an event that this customer's path will be updated/or the parent nodes need to be updated?
i'm not very sure about this design yet, so any recommendations or advise on this?
Thanks & Regards,
wesleyYou will need to create a custom BC4J domain object as a java type for XMLType and then implement the necessary fetch and update semantics. There is no built in support in BC4J framework for this type at this time.
-
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.
] -
Issue with extractvalue from table with XMLTYPE column.
I'm sure there is a simple answer but I am having problems
retrieving data from an xmltype column type.
I have two tables
descr dab_xmlName
TABLE of XMLTYPE
descr dab_testName
A NUMBER
AB NUMBER
DATA CLOB
DATA2 VARCHAR2(1600)
MYXML XMLTYPE
I have inserted the Oracle example XML purchaseOrder.xml into both dab_xml
and the myxml column in dab_test.
When I run the following:
SELECT extractvalue(OBJECT_VALUE, '/PurchaseOrder/Reference')
FROM dab_xml;
SBELL-2002100912333601PDT is returned
When I run this:
SELECT extractvalue(OBJECT_VALUE, '/PurchaseOrder/Reference')
FROM (select myxml from dab_test);
ERROR at line 1:
ORA-00904: "OBJECT_VALUE": invalid identifier
Why are the two different?
Any help will be appreciated.
Regards,
DavidIn 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. -
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. -
How to use SQL*Loader to load XMLType Column with other columns?
Hi,
I am trying to use sqlldr to load an XML file into a table with an XMLType column. I have found plenty of examples where the entire table is an xmltype, but I would like to load many XML objects into a generic table for processing with one XMLType column and many other columns to identify the load. As a simple example, I have one constant column which I want to set during the upload.
The following example does not work :(. No errors either.
create table xml_upload
(upload_type varchar2(10) not null,
xml_data XMLType)
my control file:
LOAD DATA
INFILE * append
INTO TABLE xml_upload
XMLType(xml_data)
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
upload_type constant MARKET,
xml_data
BEGINDATA
<SALE_ORDER>
<CUST_CODE>TIM</CUST_CODE>
<ORDER_NUM>1234></ORDER_NUM>
</SALE_ORDER>
$ sqlldr my.ctl
SQL*Loader: Release 10.2.0.4.0 - Production on Sun Sep 27 22:51:52 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Commit point reached - logical record count 4
SQL> select * from xml_upload;
no rows selected
SQL>
Any ideas on how I can do this? Am I missing something...
I have also been playing with the lobfile clause of sqlldr, also without any success...
Current database version is 10g R2.
Thanks,
Tim.Hi,
I tried the same example as it is. but, I am getting the following error:
SQL*Loader-350: Syntax error at line 6.
Expecting valid column specification, "," or ")", found "filler".
,file_name char(100) fillerThe table I created is:
create table xml_upload
(upload_type varchar2(10) not null,
xml_data XMLType)The control file I used is:
LOAD DATA
INFILE *
INTO TABLE xml_upload TRUNCATE
upload_type constant 'MARKET'
,file_name char(100) filler
,xml_data LOBFILE (file_name) TERMINATED BY EOF
BEGINDATA
test.xmlThe database I am using is 10gr2 -
Difficulty extracting from XMLTYPE column using XMLTABLE
Hi Folks.
I am currently trying to shred the contents of an XML document that is stored on our schema in a XMLType column. The XMLYTYPE column is pointing to several schemas that are registered within the database.
If I take a subset of the XML from one of the files and create an XMLTYPE column on the fly, I am able to extract data using the XMLTABLE syntax. If I try the same thing on the XMLTYPE column in the table registered to schemas stored in the database I get no joy.
Please see below for an example.
Please note that this is only a small segment of the original XML document which is very large. The XML document has one <RTDRFileHeader> and <ConnectionList> nodes per document but many <Connection> nodes beneath the <ConnectionList>.
My requirement is to RETRIEVE ALL the data contained in the <Connection> elements beneath the <ConnectionList>. How do I achieve this?
CREATE TABLE ag_test2 as
SELECT XMLTYPE(
'<RTDR xmlns:tadig-gen="https://infocentre.gsm.org/TADIG-GEN" xmlns="https://infocentre.gsm.org/TADIG-RTDR">
<RTDRFileHeader>
<Prefix>MRTDR</Prefix>
<Sender>EDSCH</Sender>
<Recipient>NXTMP</Recipient>
<PMN>UKRAS</PMN>
<ReportSeqNo>5</ReportSeqNo>
<TADIGGenSchemaVersion>2.2</TADIGGenSchemaVersion>
<RTDRSchemaVersion>1.1</RTDRSchemaVersion>
<CreationTmstp>2009-09-04T04:04:00.000000+02:00</CreationTmstp>
</RTDRFileHeader>
<ConnectionList xmlns="https://infocentre.gsm.org/TADIG-RTDR">
<Connection xmlns="https://infocentre.gsm.org/TADIG-RTDR">
<VPMN>UKRAS</VPMN>
<HPMN>LIEK9</HPMN>
<FileItemList>
<FileItem>
<FileID>CDUKRASLIEK901274-00005-m</FileID>
<ExchTmstp>2009-08-24T12:07:22.000000+02:00</ExchTmstp>
<FileType>
<InitTAP>
<TAPSeqNo>1274</TAPSeqNo>
<NotifFileInd>true</NotifFileInd>
<ChargeInfo>
<TAPTxCutoffTmstp>2009-08-24T12:52:10.000000+03:00</TAPTxCutoffTmstp>
<TAPAvailTmstp>2009-08-24T11:52:10.000000+02:00</TAPAvailTmstp>
<TAPCurrency>SDR</TAPCurrency>
<TotalNetCharge>0</TotalNetCharge>
<TotalTax>0</TotalTax>
</ChargeInfo>
</InitTAP>
</FileType>
</FileItem>
<FileItem>
<FileID>CDUKRASLIEK901280-00005-m</FileID>
<ExchTmstp>2009-08-30T12:14:39.000000+02:00</ExchTmstp>
<FileType>
<InitTAP>
<TAPSeqNo>1280</TAPSeqNo>
<NotifFileInd>true</NotifFileInd>
<ChargeInfo>
<TAPTxCutoffTmstp>2009-08-30T12:52:34.000000+03:00</TAPTxCutoffTmstp>
<TAPAvailTmstp>2009-08-30T11:52:34.000000+02:00</TAPAvailTmstp>
<TAPCurrency>SDR</TAPCurrency>
<TotalNetCharge>0</TotalNetCharge>
<TotalTax>0</TotalTax>
</ChargeInfo>
</InitTAP>
</FileType>
</FileItem>
</FileItemList>
</Connection>
</ConnectionList>
</RTDR> ') as xml from dual
Question: When I run the following query no rows are returned although the table is populated with XML segment above. Any explanation as to why and how can I resolve this?
SELECT rtd2."VPMN"
,rtd2."Recipient"
,rtd2."ReportSeqNo"
FROM ag_test2 r
,XMLTABLE('/RTDR'
PASSING r.xml
COLUMNS "VPMN" VARCHAR2(5) PATH '/RTDRFileHeader/ConnectionList/Connection/VPMN'
,"Recipient" VARCHAR2(5) PATH '/RTDRFileHeader/Recipient'
,"ReportSeqNo" INTEGER PATH '/RTDRFileHeader/ReportSeqNo'
) rtd2; From my other investigations the following query works OK when the same XML segment is created dynamically by performing an SELECT XMLTYPE ... FROM DUAL compared to the method above. Can anybody provide an explanation?
WITH t as (select XMLTYPE(
'<RTDR>
<RTDRFileHeader>
<Prefix>MRTDR</Prefix>
<Sender>EDSCH</Sender>
<Recipient>NXTMP</Recipient>
<PMN>UKRAS</PMN>
<ReportSeqNo>5</ReportSeqNo>
<TADIGGenSchemaVersion>2.2</TADIGGenSchemaVersion>
<RTDRSchemaVersion>1.1</RTDRSchemaVersion>
<CreationTmstp>2009-09-04T04:04:00.000000+02:00</CreationTmstp>
</RTDRFileHeader>
<ConnectionList>
<Connection>
<VPMN>UKRAS</VPMN>
<HPMN>LIEK9</HPMN>
<FileItemList>
<FileItem>
<FileID>CDUKRASLIEK901274-00005-m</FileID>
<ExchTmstp>2009-08-24T12:07:22.000000+02:00</ExchTmstp>
<FileType>
<InitTAP>
<TAPSeqNo>1274</TAPSeqNo>
<NotifFileInd>true</NotifFileInd>
<ChargeInfo>
<TAPTxCutoffTmstp>2009-08-24T12:52:10.000000+03:00</TAPTxCutoffTmstp>
<TAPAvailTmstp>2009-08-24T11:52:10.000000+02:00</TAPAvailTmstp>
<TAPCurrency>SDR</TAPCurrency>
<TotalNetCharge>0</TotalNetCharge>
<TotalTax>0</TotalTax>
</ChargeInfo>
</InitTAP>
</FileType>
</FileItem>
<FileItem>
<FileID>CDUKRASLIEK901280-00005-m</FileID>
<ExchTmstp>2009-08-30T12:14:39.000000+02:00</ExchTmstp>
<FileType>
<InitTAP>
<TAPSeqNo>1280</TAPSeqNo>
<NotifFileInd>true</NotifFileInd>
<ChargeInfo>
<TAPTxCutoffTmstp>2009-08-30T12:52:34.000000+03:00</TAPTxCutoffTmstp>
<TAPAvailTmstp>2009-08-30T11:52:34.000000+02:00</TAPAvailTmstp>
<TAPCurrency>SDR</TAPCurrency>
<TotalNetCharge>0</TotalNetCharge>
<TotalTax>0</TotalTax>
</ChargeInfo>
</InitTAP>
</FileType>
</FileItem>
</FileItemList>
</Connection>
</ConnectionList>
</RTDR> ') as xml from dual )
SELECT rtd2."VPMN"
,rtd2."HPMN"
FROM t r
,XMLTABLE('/RTDR/ConnectionList'
PASSING r.xml
COLUMNS "VPMN" VARCHAR2(5) PATH '/ConnectionList/Connection/VPMN'
,"HPMN" VARCHAR2(5) PATH '/ConnectionList/Connection/HPMN'
) rtd2;
Any comments, suggestions, pointers gratefully received.
Many thanks
Kind regards
Simon GaddSimon
It appears to work as expected for me in 11.2.0.1.0
C:\xdb\customers\Mapeley>sqlplus /nolog @testcase %CD%
SQL*Plus: Release 11.2.0.1.0 Production on Wed Nov 18 14:26:56 2009
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> spool testase.log
SQL> --
SQL> connect / as sysdba
Connected.
SQL> --
SQL> set define on
SQL> set timing on
SQL> --
SQL> define USERNAME = MAPELEY
SQL> --
SQL> def PASSWORD = &USERNAME
SQL> --
SQL> def XMLDIR = &1
SQL> --
SQL> def USER_TABLESPACE = USERS
SQL> --
SQL> def TEMP_TABLESPACE = TEMP
SQL> --
SQL> drop user &USERNAME cascade
2 /
old 1: drop user &USERNAME cascade
new 1: drop user MAPELEY cascade
User dropped.
Elapsed: 00:00:04.57
SQL> grant create any directory, drop any directory, connect, resource, alter se
ssion, create view to &USERNAME identified by &PASSWORD
2 /
old 1: grant create any directory, drop any directory, connect, resource, alte
r session, create view to &USERNAME identified by &PASSWORD
new 1: grant create any directory, drop any directory, connect, resource, alte
r session, create view to MAPELEY identified by MAPELEY
Grant succeeded.
Elapsed: 00:00:00.03
SQL> alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespa
ce &TEMP_TABLESPACE
2 /
old 1: alter user &USERNAME default tablespace &USER_TABLESPACE temporary tabl
espace &TEMP_TABLESPACE
new 1: alter user MAPELEY default tablespace USERS temporary tablespace TEMP
User altered.
Elapsed: 00:00:00.00
SQL> connect &USERNAME/&PASSWORD
Connected.
SQL> --
SQL> create or replace directory XMLDIR as '&XMLDIR'
2 /
old 1: create or replace directory XMLDIR as '&XMLDIR'
new 1: create or replace directory XMLDIR as 'C:\xdb\customers\Mapeley'
Directory created.
Elapsed: 00:00:00.01
SQL> var SCHEMAURL varchar2(256)
SQL> VAR XMLSCHEMA CLOB;
SQL> VAR INSTANCE CLOB;
SQL> VAR DOCPATH VARCHAR2(700)
SQL> --
SQL> set define off
SQL> --
SQL> alter session set events='31098 trace name context forever'
2 /
Session altered.
Elapsed: 00:00:00.01
SQL> declare
2 XMLSCHEMA XMLTYPE := XMLTYPE(bfilename('XMLDIR','tadig_gen_2.2.xsd'),NLS_
CHARSET_ID('AL32UTF8'));
3 begin
4 :SCHEMAURL:= 'tadig-gen-2.2.xsd';
5 xdb_annotate_schema.disableDefaultTables(XMLSCHEMA);
6 dbms_xmlschema.registerSchema
7 (
8 schemaurl => :SCHEMAURL,
9 schemadoc => XMLSCHEMA,
10 local => TRUE,
11 genTypes => TRUE,
12 genBean => FALSE,
13 genTables => TRUE
14 );
15 end;
16 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.17
SQL> declare
2 XMLSCHEMA XMLTYPE := XMLTYPE(bfilename('XMLDIR','tadig_rtdr.xsd'),NLS_CHA
RSET_ID('AL32UTF8'));
3 begin
4 :SCHEMAURL:= 'tadig_rtdr.xsd';
5 xdb_annotate_schema.addDefaultTable(XMLSCHEMA,'RTDR','RTDR_TABLE');
6 xdb_annotate_schema.disableDefaultTables(XMLSCHEMA);
7 dbms_xmlschema.registerSchema
8 (
9 schemaurl => :SCHEMAURL,
10 schemadoc => XMLSCHEMA,
11 local => TRUE,
12 genTypes => TRUE,
13 genBean => FALSE,
14 genTables => TRUE
15 );
16 end;
17 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:05.66
SQL> select table_name
2 from USER_XML_TABLES
3 /
TABLE_NAME
RTDR_TABLE
Elapsed: 00:00:00.04
SQL> select count(*)
2 from USER_NESTED_TABLES
3 /
COUNT(*)
17
Elapsed: 00:00:00.43
SQL> desc RTDR_TABLE
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "tadig_rtdr.xsd" Element "RTDR") STORAGE Object-r
elational TYPE "RTDR8050_T"
SQL> --
SQL> insert into RTDR_TABLE values (XMLTYPE(bfilename('XMLDIR','MRTDREDSCHNXTMPU
KRAS00001.xml'),NLS_CHARSET_ID('AL32UTF8')))
2 /
1 row created.
Elapsed: 00:00:16.91
SQL> commit
2 /
Commit complete.
Elapsed: 00:00:00.01
SQL> set autotrace on explain lines 256 long 100000 pages 0
SQL> --
SQL> SELECT rtd3."VPMN"
2 ,rtd2."Recipient"
3 ,rtd2."ReportSeqNo"
4 FROM RTDR_TABLE r
5 ,XMLTABLE
6 (
7 xmlnamespaces
8 (
9 default 'https://infocentre.gsm.org/TADIG-RTDR'
10 ),
11 '/RTDR'
12 PASSING r.object_value
13 COLUMNS
14 "ConnectionXML" XMLTYPE PATH 'ConnectionList/Connection'
15 ,"Recipient" VARCHAR2(5) PATH 'RTDRFileHeader/Recipient'
16 ,"ReportSeqNo" INTEGER PATH 'RTDRFileHeader/ReportSeqNo'
17 ) rtd2
18 ,XMLTABLE
19 (
20 xmlnamespaces
21 (
22 default 'https://infocentre.gsm.org/TADIG-RTDR'
23 ),
24 '/Connection'
25 PASSING rtd2."ConnectionXML"
26 COLUMNS
27 "VPMN" VARCHAR2(6) PATH 'VPMN'
28 ) rtd3
29 /
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
LIEK9 NXTMP 1
ABWK9 NXTMP 1
MCOK9 NXTMP 1
CHEK7 NXTMP 1
DJIK9 NXTMP 1
SGPK9 NXTMP 1
NAMK9 NXTMP 1
SENK9 NXTMP 1
NZLK9 NXTMP 1
CIV55 NXTMP 1
TURTK NXTMP 1
GINCL NXTMP 1
BFA03 NXTMP 1
NER55 NXTMP 1
DOMC9 NXTMP 1
NGA55 NXTMP 1
GRCCO NXTMP 1
GRCSH NXTMP 1
NLDPT NXTMP 1
BELTB NXTMP 1
BELMO NXTMP 1
BELKO NXTMP 1
FRAF1 NXTMP 1
FRAF3 NXTMP 1
ANDMA NXTMP 1
ESPAT NXTMP 1
ESPXF NXTMP 1
ESPTE NXTMP 1
HUNH1 NXTMP 1
HUNH2 NXTMP 1
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NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
UKRAS NXTMP 1
641 rows selected.
Elapsed: 00:00:01.15
Execution Plan
Plan hash value: 3612307998
| Id | Operation | Name | Rows | Bytes | Co
st (%CPU)| Time |
| 0 | SELECT STATEMENT | | 641 | 2539K|
9 (12)| 00:00:01 |
|* 1 | HASH JOIN | | 641 | 2539K|
9 (12)| 00:00:01 |
|* 2 | TABLE ACCESS FULL| RTDR_TABLE | 1 | 2045 |
3 (0)| 00:00:01 |
| 3 | TABLE ACCESS FULL| SYS_NTeF0jsoIcQsOueVI+sFGk0g== | 641 | 1259K|
5 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("SYS_ALIAS_0"."NESTED_TABLE_ID"="RTDR_TABLE"."SYS_NC0002300024$")
2 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.
w3.org/2001/XMLSchema-insta
nce" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xd
b/dav.xsd"><read-properties
/><read-contents/></privilege>'))=1)
Note
- dynamic sampling used for this statement (level=2)
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64
bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
C:\xdb\customers\Mapeley> -
How to upload as one row in xmltype column using sqlloader
I have the file test.xml which has data as shown below
<?xml version="1.0" encoding="ISO-8859-1">-<ops> <op><op_type>A</op_type><ent_type>A</ent_type></op>
<op><op_type>A</op_type><ent_type>A</ent_type></op>
</ops>
I need the entire data to be loaded as one row to a xmltype column.
How can I do this using sqlloader?
I tried the following, but it works only if everything is in one line.
LOAD DATA
INFILE 'test.xml'
INTO TABLE poc
(content char(1000) ENCLOSED BY '<ops>' AND '</ops>')
Is there an EOF option?XML questions (and answers) are better suited to the XDB forum...
XML DB
But in answer to your question, I don't think sqlloader is the best tool to be using for loading XML data into your database. The XDB forum has loads of examples of how to load XML into database tables. -
The simplest way to get more performance on select on xmltype column?
We have a table with xmltype column:
CREATE TABLE "TK"."PLAN_2" ("UNID" NUMBER NOT
NULL,
"XMLSTRING" "TK"."XMLTYPE",
CONSTRAINT "SYS_C001142583" PRIMARY KEY("UNID")
USING INDEX
TABLESPACE "TX"
STORAGE ( INITIAL 64K NEXT 0K MINEXTENTS 1 MAXEXTENTS
2147483645 PCTINCREASE 0) PCTFREE 10 INITRANS 2 MAXTRANS 255)
The data in column xmlstring looks like this:
<Agent>
<OP End="2520000" Id="001_8232_0_91" Origin="Autos" Quantity="1.0 ea" Start="2520000">
<OSP Key="ADM_ID" String="001_8232_0" />
<OSP Key="AddAutoNr" String="0" />
<OSP Key="CURRENT_STATE" String="Tages-Vorgabe" />
<OLP Key="ChUser">
<OIP Key="(T_SP) test2" Long="1218125408541" />
<OIP Key="(T_SP) admin" Long="1219071385346" />
<OIP Key="(T_SP) test2" Long="1237540381906" />
</OLP>
<OSP Key="Debicode" String="9903" />
<OSP Key="Resource" String="SBN" />
<OSP Key="TrafficDay" String="91" />
<OSP Key="AutoNrSchema" String="001" />
<OSP Key="AutoNumber" String="8232" />
<OPE End="0" Id="Prod" Origin="Autos|Prod" Start="0">
<OProd Duration="0" End="0" Id="Produce" OriginDirect="Autos|Prod|Produce" Quantity="1.0 ea" Start="0" Type="Produce">
<OSP Key="RESelection.Parameter" String="Resource" />
<Resource Id="Autos" />
<Alloc From="OP|001_8232_0_91|Prod|Produce" Id="" Quantity="1.0 ea" To="CO|001_8232_0_91|001_8232_0_91" Type="PRODUCEREQ_TO_CONSUMEREQ" />
</OProd>
</OPE>
<OPE End="2520000" Id="Step_0" Origin="Autos|Step" Start="0">
<OQP Key="Delay" Overridden="true" Quantity="0.0 s" />
<OQP Key="Distance" Quantity="44.84 km" />
<OQP Key="Duration" Quantity="2520.0 s" />
<OQP Key="Fahrt" Quantity="2520.0 s" />
<OSP Key="From" String="BS" />
<OSP Key="I1" String="0" />
<OSP Key="PLACE" String="1" />
<OQP Key="StartDelay" Overridden="true" Quantity="0.0 s" />
<OQP Key="TWait" Overridden="true" Quantity="0.0 s" />
<OSP Key="To" String="OL" />
<OUse Duration="2520000" End="2520000" Id="LStep_0" Name="L" OriginDirect="Autos|Step|LStep" Quantity="1.0 ea" Start="0" Type="Step">
<OSP Key="I2" String="0" />
<OIP Key="LPOSITION" Long="1" Overridden="true" />
<OSP Key="PLACE" String="1" />
<OQP Key="Wait" Overridden="true" Quantity="0.0 s" />
<Resource Id="vs_RABe525_13" />
</OUse>
<OUse Duration="480000" End="0" Id="LPre_0" Name="L" OriginDirect="Autos|Step|LPre" Quantity="1.0 ea" Start="-480000" Type="Pre">
<OQP Key="Fahrbereit" Overridden="true" Quantity="2 min" />
<OSP Key="From" Overridden="true" String="BS" />
<OSP Key="I2" String="0" />
<OSP Key="PLACE" String="1" />
<OSP Key="StepIndex" String="0" />
<OSP Key="To" Overridden="true" String="BS" />
<OQP Key="Vorbereitung" Overridden="true" Quantity="6 min" />
<Resource Id="vs_RABe525_13" />
</OUse>
<OUse Duration="600000" End="3120000" Id="LPost_0" Name="L" OriginDirect="Autos|Step|LPost" Quantity="1.0 ea" Start="2520000" Type="Post">
<OQP Key="Abstellzeit" Overridden="true" Quantity="4 min" />
<OSP Key="From" Overridden="true" String="OL" />
<OSP Key="I2" String="0" />
<OQP Key="Nachbereitung" Overridden="true" Quantity="6 min" />
<OSP Key="PLACE" String="1" />
<OSP Key="StepIndex" String="0" />
<OSP Key="To" Overridden="true" String="OL" />
<Resource Id="vs_RABe525_13" />
</OUse>
<OUse Duration="2520000" End="2520000" Id="FStep_0" Name="F" OriginDirect="Autos|Step|FStep" Quantity="1.0 ea" Start="0" Type="Step">
<OSP Key="I2" String="0" />
<OSP Key="PLACE" String="1" />
<OQP Key="Wait" Overridden="true" Quantity="0.0 s" />
<Resource Id="ps_P112" />
</OUse>
<OUse Duration="480000" End="0" Id="FPre_0" Name="F" OriginDirect="Autos|Step|FPre" Quantity="1.0 ea" Start="-480000" Type="Pre">
<OQP Key="Fahrbereit" Overridden="true" Quantity="2 min" />
<OSP Key="From" Overridden="true" String="BS" />
<OSP Key="I2" String="0" />
<OSP Key="PLACE" String="1" />
<OSP Key="StepIndex" String="0" />
<OQP Key="Taxi" Overridden="true" Quantity="0 s" />
<OSP Key="To" Overridden="true" String="BS" />
<OQP Key="Vorbereitung" O verridden="true" Quantity="6 min" />
<OQP Key="Wegzeit" Overridden="true" Quantity="0 s" />
<Resource Id="ps_P112" />
</OUse>
<OUse Duration="600000" End="3120000" Id="FPost_0" Name="F" OriginDirect="Autos|Step|FPost" Quantity="1.0 ea" Start="2520000" Type="Post">
<OQP Key="Abstellzeit" Overridden="true" Quantity="4 min" />
<OSP Key="From" Overridden="true" String="OL" />
<OSP Key="I2" String="0" />
<OQP Key="Nachbereitung" Overridden="true" Quantity="6 min" />
<OSP Key="PLACE" String="1" />
<OSP Key="StepIndex" String="0" />
<OQP Key="Taxi" Overridden="true" Quantity="0 s" />
<OSP Key="To" Overridden="true" String="OL" />
<OQP Key="Wegzeit" Overridden="true" Quantity="0 s" />
<Resource Id="ps_P112" />
</OUse>
</OPE>
</OP>
</Agent>
We try to select:
SELECT UNID, extractValue(value(OUSE_XMLSTRING), '/OUse/Resource/@Id') OUSE_RESOURCE,
extract(XMLSTRING, '/Agent/OP/OSP[@Key = "TrafficDay"]/@String') TT_DAY,
extract(XMLSTRING, '/Agent/OP/@Start') OP_START,
extract(XMLSTRING, '/Agent/OP/@End') OP_END,
extract(XMLSTRING, '/Agent/OP/OSP[@Key = "ADM_ID"]/@String') ADM_ID,
extractValue(value(OUSE_XMLSTRING), '/OUse/@Start') OUSE_START,
extractValue(value(OUSE_XMLSTRING), '/OUse/@End') OUSE_END
FROM tk.plan_2, table(XMLSequence(extract(XMLSTRING, '//Agent/OP//OPE//OUse'))) OUSE_XMLSTRING
where extractValue(value(OUSE_XMLSTRING), '/OUse/Resource/@Id') = 'vs_RABe525_13';
with this explain plan:
PLAN_TABLE_OUTPUT
Plan hash value: 3476314316
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 101 | 22018 | 31 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 101 | 22018 | 31 (0)| 00:00:01 |
| 2 | TABLE ACCESS FULL | PLAN_2 | 2 | 432 | 2 (0)| 00:00:01 |
|* 3 | COLLECTION ITERATOR PICKLER FETCH| XMLSEQUENCEFROMXMLTYPE | | | | |
Predicate Information (identified by operation id):
3 - filter(EXTRACTVALUE(VALUE(KOKBF$),'/OUse/Resource/@Id')='vs_RABe525_13')
We want to select on the 'ID', which occurs more than once in the xmlstring and the table gonna be big, so we think we need some kind of index on the ID-Identifier. What will be the best way to do this?Which version of Oracle (4 digits)?
If 10.2 or greater, look into using XMLTable and that is the replacement for the table(XMLSequence(extract()) approach. Also, avoid the use of // unless you really need it. I doubt it will make a difference in your situation but just a good performance approach in general.
We want to select on the 'ID', which occurs more than once in the xmlstringI assume you are going to want the count(...) > 1 from the XML to tell you which you are selecting?
I also have questions about what that XMLType is being stored as but that depends upon what your version is regarding what storage options you have.
Edited by: A_Non on Jun 7, 2010 10:55 AM
Forgot to add, look in the FAQ (under your sign-in name on the upper right) for how to use the tag to better format your posts. -
How to create index on a xmltype column stored as CLOB
actually i have two problems.
i uploaded this schemaA.xsd file into xmldb repository without problems. registration also went ok.
BEGIN
DBMS_XMLSCHEMA.registerSchema(
schemaURL => 'http://xmlns.example.com/xdb/documentation/schemaA.xsd'
,schemaDoc => sys.UriFactory.getUri('/home/dev/schemaA.xsd')
,local => TRUE
,genBean => false
,genTypes => TRUE
,genTables => false
,enableHierarchy => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
END;
then i run this:
create table pf_table_a(
id VARCHAR2(100) primary key,
xsd VARCHAR2(3000),
xml_document XMLType
) XMLTYPE COLUMN xml_document
STORE AS CLOB
XMLSCHEMA "http://xmlns.example.com/xdb/documentation/schemaA.xsd"
ELEMENT "order";
and got this error:
SQL> @d:\usr\dev\perftest\create_tables.sql
Table created.
create table pf_table_a(
ERROR at line 1:
ORA-00955: name is already used by an existing object
anyway the table was created. so i went on to create indexes.
SQL> create index pf_a_index on pf_table_a(extractValue(OBJECT_VALUE, '/order@or
derNo'));
create index pf_a_index on pf_table_a(extractValue(OBJECT_VALUE, '/order@orderNo
ERROR at line 1:
ORA-04063: table "BAUSER1.PF_TABLE_A" has errors
this of course is wrong. because the command is for creating index of a XMLTYPE table. no a column. but what is the correct command? thanks.
jack.actually i have two problems.
i uploaded this schemaA.xsd file into xmldb repository without problems. registration also went ok.
BEGIN
DBMS_XMLSCHEMA.registerSchema(
schemaURL => 'http://xmlns.example.com/xdb/documentation/schemaA.xsd'
,schemaDoc => sys.UriFactory.getUri('/home/dev/schemaA.xsd')
,local => TRUE
,genBean => false
,genTypes => TRUE
,genTables => false
,enableHierarchy => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
END;
then i run this:
create table pf_table_a(
id VARCHAR2(100) primary key,
xsd VARCHAR2(3000),
xml_document XMLType
) XMLTYPE COLUMN xml_document
STORE AS CLOB
XMLSCHEMA "http://xmlns.example.com/xdb/documentation/schemaA.xsd"
ELEMENT "order";
and got this error:
SQL> @d:\usr\dev\perftest\create_tables.sql
Table created.
create table pf_table_a(
ERROR at line 1:
ORA-00955: name is already used by an existing object
anyway the table was created. so i went on to create indexes.
SQL> create index pf_a_index on pf_table_a(extractValue(OBJECT_VALUE, '/order@or
derNo'));
create index pf_a_index on pf_table_a(extractValue(OBJECT_VALUE, '/order@orderNo
ERROR at line 1:
ORA-04063: table "BAUSER1.PF_TABLE_A" has errors
this of course is wrong. because the command is for creating index of a XMLTYPE table. no a column. but what is the correct command? thanks.
jack. -
How to create index on XMLType column extension?
I have an XMLType column named "info" whose corresponding global element has a complexType "InfoType" in namespace "http://example.org/ord". The "InfoType" complexType is extended in two namespaces, "http://example.org/info/zipcode" and "http://example.org/info/street". How do I create a unique index using an "InfoType" element contributed from one of the extension namespaces?
I have included below a SQL script that completely describes the problem.
Thanks in advance for your assistance?
- Ron
BEGIN
DBMS_XMLSCHEMA.registerSchema(
'chapter04prod.xsd',
'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://example.org/prod"
targetNamespace="http://example.org/prod"
elementFormDefault="unqualified">
<xsd:complexType name="ItemsType">
<xsd:sequence>
<xsd:element name="product" type="ProductType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ProductType">
<xsd:sequence>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="size" type="SizeType"/>
<xsd:element name="color" type="ColorType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SizeType">
<xsd:simpleContent>
<xsd:extension base="xsd:integer">
<xsd:attribute name="system" type="xsd:string"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="ColorType">
<xsd:attribute name="value" type="xsd:string"/>
</xsd:complexType>
</xsd:schema>',
TRUE,
TRUE,
FALSE,
FALSE);
END;
BEGIN
DBMS_XMLSCHEMA.registerSchema(
'chapter04ord1.xsd',
'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.org/ord"
xmlns="http://example.org/ord"
xmlns:prod="http://example.org/prod"
elementFormDefault="qualified">
<xsd:import namespace="http://example.org/prod"
schemaLocation="chapter04prod.xsd"/>
<xsd:simpleType name="OrderNumType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:complexType name="InfoType"/>
<xsd:complexType name="CustomerType">
<xsd:all>
<xsd:element name="name" type="CustNameType"/>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="info" type="InfoType" form="unqualified"/>
</xsd:all>
</xsd:complexType>
<xsd:simpleType name="CustNameType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:element name="order" type="OrderType"/>
<xsd:element name="customer" type="CustomerType"/>
<xsd:complexType name="OrderType">
<xsd:sequence>
<xsd:element name="number" type="OrderNumType"/>
<xsd:element name="customer" type="CustomerType"
maxOccurs="unbounded"/>
<xsd:element name="items" type="prod:ItemsType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>',
TRUE,
TRUE,
FALSE,
FALSE);
END;
BEGIN
DBMS_XMLSCHEMA.registerSchema(
'chapter04infozipcode.xsd',
'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ord="http://example.org/ord"
xmlns="http://example.org/info/zipcode"
targetNamespace="http://example.org/info/zipcode"
elementFormDefault="unqualified">
<xsd:import namespace="http://example.org/ord"
schemaLocation="chapter04ord1.xsd"/>
<xsd:complexType name="InfoType">
<xsd:complexContent>
<xsd:extension base="ord:InfoType">
<xsd:sequence>
<xsd:element name="zipcode" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>',
TRUE,
TRUE,
FALSE,
FALSE);
END;
BEGIN
DBMS_XMLSCHEMA.registerSchema(
'chapter04infostreet.xsd',
'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ord="http://example.org/ord"
xmlns="http://example.org/info/street"
targetNamespace="http://example.org/info/street"
elementFormDefault="unqualified">
<xsd:import namespace="http://example.org/ord"
schemaLocation="chapter04ord1.xsd"/>
<xsd:complexType name="InfoType">
<xsd:complexContent>
<xsd:extension base="ord:InfoType">
<xsd:sequence>
<xsd:element name="street" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>',
TRUE,
TRUE,
FALSE,
FALSE);
END;
BEGIN
DBMS_XMLSCHEMA.registerSchema(
'chapter04nonamespace.xsd',
'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ord="http://example.org/ord">
<xsd:import namespace="http://example.org/ord"
schemaLocation="chapter04ord1.xsd"/>
<xsd:element name="info" type="ord:InfoType">
</xsd:schema>',
TRUE,
TRUE,
FALSE,
FALSE);
END;
CREATE TABLE customer (
name VARCHAR(64),
number INTEGER,
info XMLTYPE)
XMLType info STORE AS OBJECT RELATIONAL
XMLSCHEMA "chapter04nonamespace.xsd"
ELEMENT "info";
INSERT INTO customer (name, number, info)
VALUES ('George Jones', 1,
XMLType(
'<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:street="http://example.org/info/zipcode"
xsi:type="zipcode:InfoType">
<zipcode>28877</zipcode>
</info>');
INSERT INTO customer (name, number, info)
VALUES ('Jim Jones', 2,
XMLType(
'<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:street="http://example.org/info/street"
xsi:type="street:InfoType">
<street>3456 Autumn Lane</street>
</info>');
SELECT name,
extractValue(info, '/info/street')
FROM customer
WHERE extractValue(info, '/info/street/text()') LIKE '3456%';
-- How does one create a unique index as follows?
CREATE UNIQUE INDEX customer_infostreet ON customer (??????);
-- The following insert should fail with unique index violation!
INSERT INTO customer (name, number, info)
VALUES ('Jerry Jones', 3,
XMLType(
'<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:street="http://example.org/info/street"
xsi:type="street:InfoType">
<street>3456 Autumn Lane</street>
</info>');Ron
Glad you found a solution.. However a more efficient solution is show below
SQL> connect sys/ as sysdba
Enter password:
Connected.
SQL> set define on
SQL> --
SQL> define USERNAME = OTNTEST
SQL> --
SQL> def PASSWORD = OTNTEST
SQL> --
SQL> def USER_TABLESPACE = USERS
SQL> --
SQL> def TEMP_TABLESPACE = TEMP
SQL> --
SQL> drop user &USERNAME cascade
2 /
old 1: drop user &USERNAME cascade
new 1: drop user OTNTEST cascade
User dropped.
SQL> grant connect, resource to &USERNAME identified by &PASSWORD
2 /
old 1: grant connect, resource to &USERNAME identified by &PASSWORD
new 1: grant connect, resource to OTNTEST identified by OTNTEST
Grant succeeded.
SQL> grant create any directory, drop any directory to &USERNAME
2 /
old 1: grant create any directory, drop any directory to &USERNAME
new 1: grant create any directory, drop any directory to OTNTEST
Grant succeeded.
SQL> grant alter session, create view to &USERNAME
2 /
old 1: grant alter session, create view to &USERNAME
new 1: grant alter session, create view to OTNTEST
Grant succeeded.
SQL> alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
2 /
old 1: alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
new 1: alter user OTNTEST default tablespace USERS temporary tablespace TEMP
User altered.
SQL> connect &USERNAME/&PASSWORD
Connected.
SQL> --
SQL> alter session set events ='19027 trace name context forever, level 0x800'
2 /
Session altered.
SQL> BEGIN
2 DBMS_XMLSCHEMA.registerSchema(
3 'chapter04prod.xsd',
4 '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/prod" targetNamespa
fault="unqualified">
5 <xsd:complexType name="ItemsType">
6 <xsd:sequence>
7 <xsd:element name="product" type="ProductType"/>
8 </xsd:sequence>
9 </xsd:complexType>
10 <xsd:complexType name="ProductType">
11 <xsd:sequence>
12 <xsd:element name="num" type="xsd:integer"/>
13 <xsd:element name="name" type="xsd:string"/>
14 <xsd:element name="size" type="SizeType"/>
15 <xsd:element name="color" type="ColorType"/>
16 </xsd:sequence>
17 </xsd:complexType>
18 <xsd:complexType name="SizeType">
19 <xsd:simpleContent>
20 <xsd:extension base="xsd:integer">
21 <xsd:attribute name="system" type="xsd:string"/>
22 </xsd:extension>
23 </xsd:simpleContent>
24 </xsd:complexType>
25 <xsd:complexType name="ColorType">
26 <xsd:attribute name="value" type="xsd:string"/>
27 </xsd:complexType>
28 </xsd:schema>',
29 TRUE, TRUE, FALSE, FALSE);
30 END;
31 /
PL/SQL procedure successfully completed.
SQL> BEGIN
2 DBMS_XMLSCHEMA.registerSchema(
3 'chapter04ord1.xsd',
4 '<xsd:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns
://example.org/prod" targetNamespace="http://example.org/ord" elementFormDefault="qualified">
5 <xsd:import namespace="http://example.org/prod" schemaLocation="chapter04prod.xsd"/>
6 <xsd:simpleType name="OrderNumType">
7 <xsd:restriction base="xsd:string"/>
8 </xsd:simpleType>
9 <xsd:complexType name="InfoType" xdb:SQLType="INFO_TYPE_T"/>
10 <xsd:complexType name="CustomerType">
11 <xsd:all>
12 <xsd:element name="name" type="CustNameType"/>
13 <xsd:element name="num" type="xsd:integer"/>
14 <xsd:element name="info" type="InfoType" minOccurs="1" form="unqualified"/>
15 </xsd:all>
16 </xsd:complexType>
17 <xsd:simpleType name="CustNameType">
18 <xsd:restriction base="xsd:string"/>
19 </xsd:simpleType>
20 <xsd:element name="customers" type="CustomersType"/>
21 <xsd:complexType name="CustomersType">
22 <xsd:sequence>
23 <xsd:element name="customer" type="CustomerType" minOccurs="0" maxOccurs="unbounded"
24 </xsd:sequence>
25 </xsd:complexType>
26 <xsd:element name="order" type="OrderType"/>
27 <xsd:element name="customer" type="CustomerType"/>
28 <xsd:complexType name="OrderType">
29 <xsd:sequence>
30 <xsd:element name="num" type="OrderNumType"/>
31 <xsd:element name="customer" type="CustomerType" maxOccurs="unbounded"/>
32 <xsd:element name="items" type="prod:ItemsType"/>
33 </xsd:sequence>
34 </xsd:complexType>
35 </xsd:schema>',
36 TRUE, TRUE, FALSE, FALSE);
37 END;
38 /
PL/SQL procedure successfully completed.
SQL> BEGIN
2 DBMS_XMLSCHEMA.registerSchema(
3 'chapter04infozipcode.xsd',
4 '<xsd:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns
//example.org/info/zipcode" targetNamespace="http://example.org/info/zipcode" elementFormDefault="unqualifie
5 <xsd:import namespace="http://example.org/ord" schemaLocation="chapter04ord1.xsd"/>
6 <xsd:complexType name="InfoType" xdb:SQLType="ZIPCODE_INFO_TYPE_T">
7 <xsd:complexContent>
8 <xsd:extension base="ord:InfoType">
9 <xsd:sequence>
10 <xsd:element name="zipcode" type="xsd:string"/>
11 <xsd:element name="suffix" type="xsd:string"/>
12 </xsd:sequence>
13 </xsd:extension>
14 </xsd:complexContent>
15 </xsd:complexType>
16 </xsd:schema>',
17 TRUE, TRUE, FALSE, FALSE);
18 END;
19 /
PL/SQL procedure successfully completed.
SQL>
SQL> BEGIN
2 DBMS_XMLSCHEMA.registerSchema(
3 'chapter04infostreet.xsd',
4 '<xsd:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns
//example.org/info/street" targetNamespace="http://example.org/info/street" elementFormDefault="unqualified"
5 <xsd:import namespace="http://example.org/ord" schemaLocation="chapter04ord1.xsd"/>
6 <xsd:complexType name="InfoType" xdb:SQLType="STREET_INFO_TYPE_T">
7 <xsd:complexContent>
8 <xsd:extension base="ord:InfoType">
9 <xsd:sequence>
10 <xsd:element name="street" type="xsd:string"/>
11 <xsd:element name="suffix" type="xsd:string"/>
12 </xsd:sequence>
13 </xsd:extension>
14 </xsd:complexContent>
15 </xsd:complexType>
16 </xsd:schema>',
17 TRUE, TRUE, FALSE, FALSE);
18 END;
19 /
PL/SQL procedure successfully completed.
SQL>
SQL> BEGIN
2 DBMS_XMLSCHEMA.registerSchema(
3 'chapter04nonamespace.xsd',
4 '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ord="http://example.org/ord">
5 <xsd:import namespace="http://example.org/ord" schemaLocation="chapter04ord1.xsd"/>
6 <xsd:element name="info" type="ord:InfoType"/>
7 </xsd:schema>',
8 TRUE, TRUE, FALSE, FALSE);
9 END;
10 /
PL/SQL procedure successfully completed.
SQL>
SQL> CREATE TABLE customer (
2 name VARCHAR(64),
3 num INTEGER,
4 info XMLTYPE)
5 XMLType info STORE AS OBJECT RELATIONAL
6 XMLSCHEMA "chapter04nonamespace.xsd"
7 ELEMENT "info";
Table created.
SQL>
SQL> INSERT INTO customer (name, num, info)
2 VALUES ('George Jones', 1,
3 XMLType(
4 '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:zipcode="http://example.org/info/zip
5 <zipcode>28877</zipcode>
6 <suffix>s1</suffix>
7 </info>'));
1 row created.
SQL>
SQL> INSERT INTO customer (name, num, info)
2 VALUES ('Jim Jones', 2,
3 XMLType(
4 '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:street="http://example.org/info/stre
5 <street>3456 Autumn Lane</street>
6 <suffix>s2</suffix>
7 </info>'));
1 row created.
SQL> /
1 row created.
SQL> SELECT name,
2 extractValue(info, '/info/zipcode'),
3 extractValue(info, '/info/street')
4 FROM customer
5 WHERE extractValue(info, '/info/zipcode/text()') LIKE '2%'
6 OR extractValue(info, '/info/street/text()') LIKE '3456%';
NAME
EXTRACTVALUE(INFO,'/INFO/ZIPCODE')
EXTRACTVALUE(INFO,'/INFO/STREET')
George Jones
28877
Jim Jones
3456 Autumn Lane
NAME
EXTRACTVALUE(INFO,'/INFO/ZIPCODE')
EXTRACTVALUE(INFO,'/INFO/STREET')
Jim Jones
3456 Autumn Lane
SQL>
SQL> CREATE UNIQUE INDEX customer_infozipcode ON customer(
2 extractValue
3 (
4 info,
5 '/info[@xsi:type="zipcode:InfoType"]/zipcode',
6 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7 xmlns:zipcode="http://example.org/info/zipcode"'
8 ))
9 /
Index created.
SQL> select column_name
2 from user_ind_columns
3 where INDEX_NAME = 'CUSTOMER_INFOZIPCODE'
4 /
COLUMN_NAME
SYS_NC00014$
SQL> select INDEX_NAME,COLUMN_EXPRESSION
2 from user_ind_expressions
3 /
INDEX_NAME
COLUMN_EXPRESSION
CUSTOMER_INFOZIPCODE
EXTRACTVALUE(SYS_MAKEXML('0341F05603124922B4F6F94DC5E30C2F',4870,"SYS_NC00004$",
SQL> DROP INDEX CUSTOMER_INFOZIPCODE
2 /
Index dropped.
SQL> desc INFO_TYPE_T
INFO_TYPE_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
SQL> --
SQL> desc ZIPCODE_INFO_TYPE_T
ZIPCODE_INFO_TYPE_T extends OTNTEST.INFO_TYPE_T
ZIPCODE_INFO_TYPE_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
zipcode VARCHAR2(4000 CHAR)
suffix VARCHAR2(4000 CHAR)
SQL> --
SQL> desc STREET_INFO_TYPE_T
STREET_INFO_TYPE_T extends OTNTEST.INFO_TYPE_T
STREET_INFO_TYPE_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
street VARCHAR2(4000 CHAR)
suffix VARCHAR2(4000 CHAR)
SQL> --
SQL> CREATE UNIQUE INDEX customer_infozipcode ON customer(TREAT(INFO.XMLDATA AS ZIPCODE_INFO_TYPE_T)."zipcod
2 /
Index created.
SQL> select column_name
2 from user_ind_columns
3 where INDEX_NAME = 'CUSTOMER_INFOZIPCODE'
4 /
COLUMN_NAME
TREAT("SYS_NC00007$" AS "ZIPCODE_INFO_TYPE_T")."zipcode"
SQL> select INDEX_NAME,COLUMN_EXPRESSION
2 from user_ind_expressions
3 /
no rows selected
SQL> INSERT INTO customer (name, num, info)
2 VALUES ('Jerry Jones', 3,
3 XMLType(
4 '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:zipcode="http://example.org/info/zip
5 <zipcode>28877</zipcode>
6 <suffix>s1</suffix>
7 </info>'))
8 /
INSERT INTO customer (name, num, info)
ERROR at line 1:
ORA-00001: unique constraint (OTNTEST.CUSTOMER_INFOZIPCODE) violated
SQL> INSERT INTO customer (name, num, info)
2 VALUES ('Jerry Jones', 3,
3 XMLType(
4 '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:street="http://example.org/info/stre
5 <street>3456 Autumn Lane</street>
6 <suffix>s3</suffix>
7 </info>'))
8 /
1 row created.
SQL>In you solution a functional index was created. In my case, by breaking the XML abstraction, and using object-relational SQL to create the index (DDL statements are the one case where I feel this is acceptable) I was able to create a pure B-TREE index which has the same effect.. -
Bug in SQL Developer relating to handling of XMLTYPE columns
Hi,
I have found a bug in SQL Developer relating to its handling of XMLTYPE columns.
Given a table with the following data:
ID, XML_DATA
1, <xml here>
2, <xml here>
3, <xml here>
And the following SQL to extract a value from the XML and also an XML fragment as an XMLTYPE:
SELECT
EXTRACTVALUE(t.column_value,'/*/USER_ID/text()')user_id
, t.column_value user_data
FROM dbuser.mytable m
, TABLE(XMLSEQUENCE(EXTRACT(m.xml_data, '/*/USER_LIST/USER'))) t
I get the following:
user_id, user_data
jsmith26, (XMLTYPE)
mjones45, (XMLTYPE)
sborga31, (XMLTYPE)
Note that the user_id is correctly extracted, however the XMLTYPE column (user_data) is empty in SQL Developer.
The same query returns the correct XML data in TOAD.
Edited by: 1008733 on May 29, 2013 5:07 PMSteve,
So your example is slightly more complex than the one documented for a table in the standard OE schema here:
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions052.htm
That example works fine on an 11.2.0.1 database with SQL Developer 3.2.20.09.87. Please try the following with your case:
Tools -> Preferences -> Database -> Advanced -> Display Struct Value In Grid (check it off if not already)If that still does not work for Run Statement (query result displayed in the grid, not as script output using Run Script), then please provide a test case based on the Warehouse table in the OE schema (or your case with DDL and DML scripts including the xml data) and I will log a bug.
Thanks,
Gary
SQL Developer Team -
Problem query of XMLType column in XSQL servlet
Hi all,
I'm having trouble debugging the following error from a query on an XMLType column in an XSQL page query:
<page xmlns:xsql="urn:oracle-xsql" connection="jdbc/DBConnection1DS">
<xsql:query max-rows="1" null-indicator="no">
SELECT extractValue(x.DOCBOOKS_DOC, '/book/part/title', 'xmlns="http://docbook.org/ns/docbook"') "BOOK TITLE"
FROM DOCBOOKS_STORE x
</xsql:query>
</page>
which returns the following error message:
<page>
<ERROR>
oracle.xml.sql.OracleXMLSQLException: Character ' ' is not allowed in an XML tag name.
</ERROR>
</page>
The SQL query works fine in the SQL Worksheet and SQL Plus, only when I stick it in an XSQL query. I've tested the XSQL Page environment with a query on Number Datatype column and no issues there either.
Any suggestions, much appreciated. Thanks.
GeorgeThe XML SQL Utility creates XML tags named after your column aliases.
You have aliased the column to a name containing a space: "BOOK TITLE"
This error is telling you that the implied XML element whose name matches this column alias, which would be <BOOK TITLE> is not a legal name for an XML element since it has a space in it.
You'll need to pick a column alias with no space in the name. For example, "BOOK_TITLE" and then in your XSLT stylesheet (or whatever downstream formatting tool you may be using) remove the underscore from the name and replace it with a space.
Maybe you are looking for
-
I have a failure on Port 6 of my PXI-6515 caused, I believe, by pins 49 & 50 on the cable lead from my SBC-100 being out of line. They therefore did not engage with the PXI card properly shorting themselves together and maybe connecting with one of
-
Functional Module required for getting list of successful jobs
Hi All, There is one function module BP_JOB_SELECT which gives me name of unsuccessful job. Now I want to find the name of all successful job. Can anyone please tell me the function module name for that? Thanks in advance, Siddarth.
-
Related to attachment of query to apporoval document
hi i want to attach query to approval template and i want approval as per the query result so what is step for that and please replay me regards sandip
-
[SOLVED] xfce4 mystery
Hi I'm a newbie to Arch, but not to xfce. Xfce4 was installed as indicated in the wiki with everything and the 'goodies' too. Problems: 1) There does not appear to be any window manager in effect. All my windows are borderless and have no buttons. 2)
-
Finding Latest Files added to hard drive
I've got a peculiar problem here. Since yesterday or the day before my available hard drive space has dropped around 3 gigabytes. Thing is, I've installed nothing, downloaded nothing, nor added nothing to the computer. Is there a way to perform a sea