Xml in pl/sql
i want 2 create an xml using pl/sql. oracle web agent must be installed and and xml utilities for pl/sql
im using win2000 and im connected to ora8.1.6
in linux. where do i need to install this 2 software. in the server or in my client pc?
thanks in advance.
regards
jerome
You should install the XML SQL Utility for PL/SQL in your database. It is basically a set of JAVA classes that get loaded into the database. You will use the PL/SQL packages to access the methods on these classes. You should use the DBMS_XMLQUERY and DBMS_XMLSAVE packages.
You can run the install from your client.
Similar Messages
-
Hi all,
I have the following xml file (books1.xml):
<bookstore>
<book>
<BookID>1</BookID>
<title>Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book>
<BookID>2<BookID>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book>
<BookID>3<BookID>
<title>XQuery Kick Start</title>
<author>James McGovern</author>
<year>2003</year>
<price>49.99</price>
</book>
<book>
<BookID>4<BookID>
<title>Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
In my Microsoft SQL Server 2012 Management Studio, I executed the following SQL Query code:
--XQuery w3schools example using books1.xml in C:\Temp folder
---SQL Query W3books Title
---9 March 2015
USE XML_XQUERY
GO
CREATE TABLE W3Books(
BookID INt Primary Key,
Title VARCHAR(30));
INSERT INTO W3Books (BookID, Title)
SELECT x.book.query('BookID'), value('.', 'INT'),
x.book.query('title'), value('.', 'VARCHAR(30)')
FROM (
SELECT CAST(x AS XML)
FROM OPENROWSET(
BULK 'C:\Temp\books1.xml',
SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY x.nodes('W3Books/book') AS x(book);
SELECT BookID, Title
FROM W3Books;
I got the following error messages:
Msg 195, Level 15, State 10, Line 7
'value' is not a recognized built-in function name.
Msg 156, Level 15, State 1, Line 16
Incorrect syntax near the keyword 'AS'.
I don't know why I got the error of 'value' is not a recognized built-in function name. Please kindly help and tell me what is wrong in my code and how to correct the error.
Thanks, Scott Chang
P. S.
(1) I mimicked the xml file and SQL Qeury code of Import XML File to SQL Table in
http://pratchev.blogspot.com/2008/11/import-xml-file-to-sql-table.html. The xml file and the code of this sample worked in my SSMS 2012 program.
(2) I am learning the "CAST" and "CROSS APPLY" in the Create Instances of XML Data of Microsoft MSDN - it is very abstract to me.Hi Stan210, Thanks for your nice response.
I corrected my xml file as you pointed out.
I made some changes in some code statements of my SQLQueryW3BookTitle.sql as you instructed:
--XQuery w3schools example using books1.xml in C:\Temp folder
---SQL Query W3books Title
---10 March 2015
USE XML_XQUERY
GO
CREATE TABLE W3Books(
BookID INt Primary Key,
Title VARCHAR(30));
INSERT INTO W3Books (BookID, Title)
SELECT x.book.value('/BookID[1]', 'INT'),
x.book.value('/title[1]', 'VARCHAR(30)')
FROM (
SELECT CAST(x AS XML)
FROM OPENROWSET(
BULK 'C:\Temp\books1.xml',SINGLE_BLOB) AS T(x)
) AS T(x)
CROSS APPLY x.nodes('bookstore/book') AS x(book);
SELECT BookID, Title
FROM W3Books;
I executed my revised sql and I got the following Message and Results:
Msg 515, Level 16, State 2, Line 6
Cannot insert the value NULL into column 'BookID', table 'XML_XQUERY.dbo.W3Books'; column does not allow nulls. INSERT fails.
The statement has been terminated.
(0 row(s) affected)
Results:
BookID Title
I don't know why I just got the names of columns in Results and the "Cannot insert the value NULL into column 'BookID', table 'XML_XQUERY.dbo.W3Books'; column does not allow nulls, insert fails." in Messages. Please kindly help, advise me
how to correct the errors and respond again.
Many Thanks again,
Scott Chang -
XML parsing with SQL/PL-SQL
Hi,
My question is about how can an XML message can be best parsed using SQL/PL-SQL.
The scenario is as follow. The XML message is stored in a CLOB; only some of its data needs to be extracted; there are six different types of structures of XML; the size of each XML is about 50 lines (maximum depth level is 3); the data could be written in English or Greek or French or German or Russian; this is going to be done every hour and the parsing is going to be against 3,000 records approx.
In the development, I need to take into consideration performance. We are using Oracle 10, but we could migrate to Oracle 11 if necessary.
Apologies for this basic question but I have never done XML parsing in SQL/PL-SQL before.
Thank you.
PS I have copied this question to the XML forum.
Edited by: user3112983 on May 19, 2010 3:30 PM
Edited by: user3112983 on May 19, 2010 3:39 PMuser3112983 wrote:
The scenario is as follow. The XML message is stored in a CLOB; only some of its data needs to be extracted; there are six different types of structures of XML; the size of each XML is about 50 lines (maximum depth level is 3); the data could be written in English or Greek or French or German or Russian; this is going to be done every hour and the parsing is going to be against 3,000 records approx.Parsing is done using the XMLTYPE data type (object class) in Oracle.
Something as follows:
SQL> create table xml_doc( id number, doc clob );
Table created.
SQL>
SQL> insert into xml_doc values( 1, '<root><row><name>John</name></row><row><name>Jack</name></row></root>' );
1 row created.
SQL> commit;
Commit complete.
SQL>
SQL> declare
2 rawXml xml_doc.doc%type;
3 xml xmltype;
4 begin
5 -- get the raw XML (as a CLOB)
6 select doc into rawXml from xml_doc where id = 1;
7
8 -- parse it
9 xml := new xmltype( rawXml );
10 -- process the XML...
11 end;
12 /
PL/SQL procedure successfully completed.
SQL>The variable xml in the sample code is the XML DOM object. XML functions can be used against it (e.g. to extract values in a tabular row and column structure).
Note that the CLOB needs to contain a valid XML. An XML containing XML fragments is not valid and cannot be parsed. E.g.
SQL> declare
2 xml xmltype;
3 begin
4 -- attemp to parse fragments
5 xml := new xmltype( '<row><name>John</name></row> <data><column>Name</column></data>' );
6 end;
7 /
declare
ERROR at line 1:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00245: extra data after end of document
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 301
ORA-06512: at line 5This XML contains 2 fragments. A row structure and a data structure. It is not a valid XML and as such cannot be parsed. If a root tag is used to encapsulate these 2 fragments, then it will be a valid XML structure.
In the development, I need to take into consideration performance. We are using Oracle 10, but we could migrate to Oracle 11 if necessary.Have not run into any XML performance problems specifically - and am using it extensively. Even large XMLs (10's of 1000's of elements) parse pretty fast. -
Loading XML file in SQL Developer become ONE ROW !!
Hi:
I load the XML file to SQL Developer.
I found out that the XML files data are in one ROW?
Am I right?
Please let me know please
SemHi RAGS1109,
If our XML data starts to get more complicated (multiple levels of elements / attributes), we start getting more outputs, we will have to join those outputs with a merge join transform.
Please refer to the following document how to dealing with multiple outputs for XML data source:
Using XML Source:
http://blogs.msdn.com/b/mattm/archive/2007/12/11/using-xml-source.aspx
Process Multi-Level XML in SSIS:
http://www.youtube.com/watch?v=rFgLV58EcXA
If you have any feedback on our support, please click
here.
Elvis Long
TechNet Community Support -
Hi,
What is the best way to create large XML in pl/sql?? and to read large XML from CLOB procedure parameter?????
ThanksUse the internal XML-structures of the database, such as XMLType, XMLElement, XMLForrest. Have a look at the XMLDB-documentation.
-
Hi,
I have a data stored in table in XML format in a clob column. When I query the table containing the XML data only part of the XML is shown in SQL*Plus. Is there anyway that I can view the full XML data in SQL* Plus prompt?
Thanks,
Milton.The SET LOBOFFSET, SET LONG and SET LONGCHUNKSIZE values affect how SQL*Plus fetches from CLOBs.
See http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/server.920/a90842/ch13.htm#1012674
-- CJ -
Problem loading XML-file using SQL*Loader
Hello,
I'm using 9.2 and tryin to load a XML-file using SQL*Loader.
Loader control-file:
LOAD DATA
INFILE *
INTO TABLE BATCH_TABLE TRUNCATE
FIELDS TERMINATED BY ','
FILENAME char(255),
XML_DATA LOBFILE (FILENAME) TERMINATED BY EOF
BEGINDATA
data.xml
The BATCH_TABLE is created as:
CREATE TABLE BATCH_TABLE (
FILENAME VARCHAR2 (50),
XML_DATA SYS.XMLTYPE ) ;
And the data.xml contains the following lines:
<?xml version="2.0" encoding="UTF-8"?>
<!DOCTYPE databatch SYSTEM "databatch.dtd">
<batch>
<record>
<data>
<type>10</type>
</data>
</record>
<record>
<data>
<type>20</type>
</data>
</record>
</batch>
However, the sqlldr gives me an error:
Record 1: Rejected - Error on table BATCH_TABLE, column XML_DATA.
ORA-21700: object does not exist or is marked for delete
ORA-06512: at "SYS.XMLTYPE", line 0
ORA-06512: at line 1
If I remove the first two lines
"<?xml version="2.0" encoding="UTF-8"?>"
and
"<!DOCTYPE databatch SYSTEM "databatch.dtd">"
from data.xml everything works, and the contentents of data.xml are loaded into the table.
Any idea what I'm missing here? Likely the problem is with special characters.
Thanks in advance,I'm able to load your file just by removing the second line <!DOCTYPE databatch SYSTEM "databatch.dtd">. I dont have your dtd file, so skipped that line. Can you check if it's problem with ur DTD?
-
How to parsing xml data in sql statement??
Hi friends, I have a table which contain column as clob ,stores in xml format, for example my column contain xml data like this
<Employees xmlns="http://TargetNamespace.com/read_emp">
<C1>106</C1>
<C2>Harish</C2>
<C3>1998-05-12</C3>
<C4>HR</C4>
<C5>1600</C5>
<C6>10</C6>
</Employees>
Then how to extract the data in above xml column data using SQL statement...Duplicate post
How to parsing xml data in sql statement?? -
Hi All,
I am trying to use XML for building an application. Is it
possible to generate page by only using a PL-SQL?
I know how to generate XML by using PL-SQL.
--How can I apply XSL document to it?
Thanks,
SamirThe XML Developers kit available on this site at: http://technet.oracle.com/tech/xml/
contains utilities for parsing XML with PL/SQL and other methods. -
Generating XML through PL/SQL
Hi everyone,
I got a new task at work, and my task is to generate XML through PL/SQL.
I am using Oracle 11g database, and SQL Developer 3.0.
The purpose of this procedure is to upload xml file to a queue, so my BPEL process can access the queue and do what it does.
This is my first time writing a procedure that generates xml so bear with me.
Below is a sample of the xml file I received. I need to generate xml file below through PL/SQL. All the information in xml file will need to be retrieved from the database.
I need your help to start working on this procedure. Your help is very much appreciated.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body xmlns:ns1="http://www.ussc.gov/soa/casefile/event/types">
<caseFileUploadEvent xmlns:xsi="http://www.w3XX.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.XXXX.gov/soa/casefile/event/types ../xsd/Case_META.xsd"
xmlns="http://www.XXXX.gov/soa/casefile/event/types">
<taskEvent>SUBMIT</taskEvent>
<defendentDetails>
<sentensingDate>2008-11-10-05:00</sentensingDate>
<personDetails>
<personNameDetails>
<firstName>FIRSTNAME</firstName>
<middleName>B</middleName>
<lastName>LASTNAME</lastName>
</personNameDetails>
<dateOfBirth>1969-09-23-04:00</dateOfBirth>
</personDetails>
</defendentDetails>
<documentStatusDetails>
<otherStatus>
<intCode>61</intCode>
<description>Other documents included</description>
</otherStatus>
</documentStatusDetails>
<uploadOtherDetails>
<submissionId>427000447</submissionId> // NOTE: SUBMISSIONID WILL BE PASSED IN THROUGH THE PROCEDURE TO QUERY ALL THE INFORMATION NEEDED FOR THE XML FILE
<submissionSessionId>401622</submissionSessionId>
<submissionMethod>
<intCode>1</intCode>
<description>WebApplication</description>
</submissionMethod>
<submissionReason>
<intCode>1</intCode>
<description>InitialSubmission</description>
</submissionReason>
<district>
<intCode>99</intCode>
<description>Test District</description>
</district>
<caseFileType>
<intCode>10</intCode>
<description>Individual - Original</description>
</caseFileType>
<primaryDocketInfo>
<yearYY>5</yearYY>
<id>55555</id>
<defendentNumber>555</defendentNumber>
</primaryDocketInfo>
<PACTSId>55555555</PACTSId>
<AOJudgeId>
<intCode>2512</intCode>
<description>FABER, DAVID, A.</description>
</AOJudgeId>
<missingCasefile>false</missingCasefile>
<creator>
<firstName>will</firstName>
<lastName>smith</lastName>
<email>[email protected]</email>
<actionDate>2005-09-07T09:48:09.811-04:00</actionDate>
</creator>
<lastModifier>
<firstName>john</firstName>
<lastName>doe</lastName>
<email>[email protected]</email>
<actionDate>2006-10-03T08:51:21.5-04:00</actionDate>
</lastModifier>
</uploadOtherDetails>
</caseFileUploadEvent>
</soap:Body>
</soap:Envelope>procedure below
procedure upload_process(submission_id number) as
begin
-- retrieve information from database based on submission_id (passed in)
-- generate XML
-- send xml to queue
end upload_process;ThanksRooney,
First of all, I would use Oracle package UTL_DBWS to handle web service calls.
But if you choose to do all the work yourself to call web service, this is one of the options:
Since the size of your xml soap request is about 4k, you can just use pl/sql varchar2 variable to construct your xml.
Example:
cSoapRequest VARCHAR2(5000);
BEGIN
cSoapRequest := '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body xmlns:ns1="http://www.ussc.gov/soa/casefile/event/types">
<caseFileUploadEvent xmlns:xsi="http://www.w3XX.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.XXXX.gov/soa/casefile/event/types ../xsd/Case_META.xsd"
xmlns="http://www.XXXX.gov/soa/casefile/event/types">';
FOR recRow IN <your cursor> LOOP
cSoapRequest := cSoapRequest || '<dateOfBirth>'|| TO_CHAR(recRow.DOB,'YYYY-MM-DD HH:MI' )|| '</dateOfBirth>';
END LOOP;
...Then use package utl_http to send the request and recieve response.
Google pl/sql webservice,
Here is one:
Calling Web Service from PL/SQL (ORA-31011: XML parsing failed)
Hope this will give you an idea.
Thomas -
Save whole XML file in SQL table field
Hi All,
I want to save whole XML message in sql table field which is with datatype XML(.).. how can i achieve this.
Thanks in advance.
2Venture2I did a prototype to do what you are asking. I actually haven't inserted into the xml data type in SQL Server before, so I was curious if that added any complexity. I'll just go through the mapping pieces and assume that you can easily find documentation
on how to insert data into SQL Server using the Add Generated Items --> Consume Adapter Service function.
The interesting piece was writing the map. I used a simple PO schema. My sample table was XmlRepository with a ID column, RepositoryID, and the RawXml field.
The script is an inline XSLT script that is as follows:
<xsl:element name="ns3:RawXml">
<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
<xsl:copy-of select="/" />
<xsl:text disable-output-escaping="yes">]]></xsl:text>
</xsl:element>
The questoin right off is why the CDATA? Well, since the value of the RawXml element that needs to be inserted into SQL Server is XML data, it has to be wrapped in a CDATA tag. Otherwise, the XML data gets validated and will not properly make it to the SQL
Server. You can try it and see what I mean. Don't worry, the CDATA gets stripped before the XML gets written to the table.
The interesting piece are the xsl:text elements, which manually create a CDATA wrapper for the XML that ends up in the RawXml field. Apparently, the normal Grid Property for creating CDATA output doesn't work in conjunction with the xsl:copy-of function.
That tripped me up for a while!
What the map outputs is a document that looks like the following:
<ns0:Insert xmlns:array="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:ns3="http://schemas.microsoft.com/Sql/2008/05/Types/Tables/dbo" xmlns:ns0="http://schemas.microsoft.com/Sql/2008/05/TableOp/dbo/XmlRepository">
<ns0:Rows>
<ns3:XmlRepository>
<ns3:RawXml>
<![CDATA[<ns0:PurchaseOrder xmlns:ns0="http://XmlRepositoryDemo.PurchaseOrder">
<PONumber>PONumber_0</PONumber>
<CustomerNumber>CustomerNumber_0</CustomerNumber>
<PODate>PODate_0</PODate>
<Items>
<Item>
<ProductID>ProductID_0</ProductID>
<Quantity>Quantity_0</Quantity>
<Price>Price_0</Price>
</Item>
</Items>
</ns0:PurchaseOrder>]]>
</ns3:RawXml>
</ns3:XmlRepository>
</ns0:Rows>
</ns0:Insert>
The map can be called from a simple Orchestration, or even a messaging-only scenario, and sent across the wire in a request/reply as you would for normally sending data to SQL Server.
I hope this helps. It ended up being more interesting than I expected! -
Creating hierarchical XML from MS SQL
Hello,
I am trying to create a hierarchical XML from MS SQL database. I have got a SQL running:
select distinct
1 as Tag,
NULL as Parent,
X_SEQ_NUM as [Invoice!1!Invoice_Num!element],
COALESCE(INV.ADJUSTMENT_AMT,0) as [Invoice!1!Adjusted_Total!element],
Null as [Item!2!CostedAccrual!element],
Null as [Item!2!QuotAcc!element],
Null as [Item!2!Prod_Name!element]
from S_INVOICE INV
inner join S_INVOICE_ITEM ITEM on (ITEM.INVOICE_ID = INV.ROW_ID)
inner join S_PROD_INT PROD on (PROD.ROW_ID = ITEM.PROD_ID)
where
INV.X_TAX_POINT_DT between '2010-02-01' and '2010-02-15'
and (PROD.X_FREIGHT_FLG = 'Y' or PROD.X_INT_PROD_FLAG = 'Y')
and X_SEQ_NUM = '1066505'
UNION ALL
select distinct
2 as Tag,
1 as Parent,
INV.X_SEQ_NUM ,
COALESCE(INV.ADJUSTMENT_AMT,0),
COALESCE(ITEM.X_UNIT_PRI,0) as CostedAccrual, --costed accrual
COALESCE(ITEM.X_QUOTED_AMT,0)/ITEM.X_EXCHANGE_RATE as QuotAcc,
PROD.NAME as Prod_Name
from S_INVOICE INV
inner join S_INVOICE_ITEM ITEM on (ITEM.INVOICE_ID = INV.ROW_ID)
inner join S_PROD_INT PROD on (PROD.ROW_ID = ITEM.PROD_ID)
where
INV.X_TAX_POINT_DT between '2010-02-01' and '2010-02-15'
and (PROD.X_FREIGHT_FLG = 'Y' or PROD.X_INT_PROD_FLAG = 'Y')
and X_SEQ_NUM = '1066505'
ORDER by 3, 7
for XML EXPLICIT
( we are on a siebel created db)
and I get the following
<?xml version="1.0" encoding="UTF-8" ?>
- <ROWSET>
- <ROW>
- <XML_F52E2B61-18A1-11d1-B105-00805F49916B>
- <Invoice>
<Invoice_Num>1066505</Invoice_Num>
<Adjusted_Total>220.0000000</Adjusted_Total>
- <Item>
<CostedAccrual>200.0000000</CostedAccrual>
<QuotAcc>0.00000000000000000000000</QuotAcc>
<Prod_Name>Third Party Services</Prod_Name>
</Item>
</Invoice>
</XML_F52E2B61-18A1-11d1-B105-00805F49916B>
</ROW>
</ROWSET>
(Apologies for the lack of outlining)
My question is about the the line "XML_F52E...." as it isn't right and I'm not sure how to proceed.
Any thoughts?
Thank you in advance.
RichardHi Richard,
Not sure, if i got it correctly.
You are talking abt the element name ?
then, always give meaningful short name to columns in the query. -
Parse complex XML in PL/SQL
have complex XML with depth level 10. I need to parse and store data into tables from XML. I am able to parse simple XML but not complex. Could any body suggest me the required steps to parse complex XML in PL/SQL?
Based on response from mdrake on this thread:
Re: XML file processing into oracle
Reading XML using a schema...
declare
SCHEMAURL VARCHAR2(256) := 'http://xmlns.example.org/xsd/testcase.xsd';
XMLSCHEMA VARCHAR2(4000) := '<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
<xs:element name="cust_order" type="cust_orderType" xdb:defaultTable="CUST_ORDER_TBL"/>
<xs:complexType name="groupType" xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="item" type="itemType" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="id" type="xs:byte" use="required"/>
</xs:complexType>
<xs:complexType name="itemType" xdb:maintainDOM="false">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:short" use="required"/>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="cust_orderType" xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="group" type="groupType" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="cust_id" type="xs:short" use="required"/>
</xs:complexType>
</xs:schema>';
INSTANCE CLOB :=
'<cust_order cust_id="12345">
<group id="1">
<item id="1" name="Standard Mouse">100</item>
<item id="2" name="Keyboard">100</item>
<item id="3" name="Memory Module 2Gb">200</item>
<item id="4" name="Processor 3Ghz">25</item>
<item id="5" name="Processor 2.4Ghz">75</item>
</group>
<group id="2">
<item id="1" name="Graphics Tablet">15</item>
<item id="2" name="Keyboard">15</item>
<item id="3" name="Memory Module 4Gb">15</item>
<item id="4" name="Processor Quad Core 2.8Ghz">15</item>
</group>
<group id="3">
<item id="1" name="Optical Mouse">5</item>
<item id="2" name="Ergo Keyboard">5</item>
<item id="3" name="Memory Module 2Gb">10</item>
<item id="4" name="Processor Dual Core 2.4Ghz">5</item>
<item id="5" name="Dual Output Graphics Card">5</item>
<item id="6" name="28inch LED Monitor">10</item>
<item id="7" name="Webcam">5</item>
<item id="8" name="A3 1200dpi Laser Printer">2</item>
</group>
</cust_order>';
begin
dbms_xmlschema.registerSchema
schemaurl => SCHEMAURL
,schemadoc => XMLSCHEMA
,local => TRUE
,genTypes => TRUE
,genBean => FALSE
,genTables => TRUE
,ENABLEHIERARCHY => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
execute immediate 'insert into CUST_ORDER_TBL values (XMLTYPE(:INSTANCE))' using INSTANCE;
end;
desc CUST_ORDER_TBL
--SQL> desc CUST_ORDER_TBL
-- Name Null? Type
-- TABLE of SYS.XMLTYPE(XMLSchema "http://xmlns.example.org/xsd/testcase.xsd" Element "cust_order") STORAGE Object-relational TYPE "cust_orderType222_T"
set autotrace on explain
set pages 60 lines 164 heading on
col cust_id format a8
select extract(object_value,'/cust_order/@cust_id') as cust_id
,grp.id as group_id, itm.id as item_id, itm.inm as item_name, itm.qty as item_qty
from CUST_ORDER_TBL
,XMLTABLE('/cust_order/group'
passing object_value
columns id number path '@id'
,item xmltype path 'item'
) grp
,XMLTABLE('/item'
passing grp.item
columns id number path '@id'
,inm varchar2(30) path '@name'
,qty number path '.'
) itm
CUST_ID GROUP_ID ITEM_ID ITEM_NAME ITEM_QTY
12345 1 1 Standard Mouse 100
12345 1 2 Keyboard 100
12345 1 3 Memory Module 2Gb 200
12345 1 4 Processor 3Ghz 25
12345 1 5 Processor 2.4Ghz 75
12345 2 1 Graphics Tablet 15
12345 2 2 Keyboard 15
12345 2 3 Memory Module 4Gb 15
12345 2 4 Processor Quad Core 2.8Ghz 15
12345 3 1 Optical Mouse 5
12345 3 2 Ergo Keyboard 5
12345 3 3 Memory Module 2Gb 10
12345 3 4 Processor Dual Core 2.4Ghz 5
12345 3 5 Dual Output Graphics Card 5
12345 3 6 28inch LED Monitor 10
12345 3 7 Webcam 5
12345 3 8 A3 1200dpi Laser Printer 2
17 rows selected.Need at least 10.2.0.3 for performance i.e. to avoid COLLECTION ITERATOR PICKLER FETCH in execution plan...
On 10.2.0.1:
Execution Plan
Plan hash value: 3741473841
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 24504 | 89M| 873 (1)| 00:00:11 |
| 1 | NESTED LOOPS | | 24504 | 89M| 873 (1)| 00:00:11 |
| 2 | NESTED LOOPS | | 3 | 11460 | 805 (1)| 00:00:10 |
| 3 | TABLE ACCESS FULL | CUST_ORDER_TBL | 1 | 3777 | 3 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | SYS_IOT_TOP_774117 | 3 | 129 | 1 (0)| 00:00:01 |
| 5 | COLLECTION ITERATOR PICKLER FETCH| XMLSEQUENCEFROMXMLTYPE | | | | |
Predicate Information (identified by operation id):
4 - access("NESTED_TABLE_ID"="CUST_ORDER_TBL"."SYS_NC0000900010$")
filter("SYS_NC_TYPEID$" IS NOT NULL)
Note
- dynamic sampling used for this statementOn 10.2.0.3:
Execution Plan
Plan hash value: 1048233240
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 17 | 132K| 839 (0)| 00:00:11 |
| 1 | NESTED LOOPS | | 17 | 132K| 839 (0)| 00:00:11 |
| 2 | MERGE JOIN CARTESIAN | | 17 | 131K| 805 (0)| 00:00:10 |
| 3 | TABLE ACCESS FULL | CUST_ORDER_TBL | 1 | 3781 | 3 (0)| 00:00:01 |
| 4 | BUFFER SORT | | 17 | 70839 | 802 (0)| 00:00:10 |
|* 5 | INDEX FAST FULL SCAN| SYS_IOT_TOP_56154 | 17 | 70839 | 802 (0)| 00:00:10 |
|* 6 | INDEX UNIQUE SCAN | SYS_IOT_TOP_56152 | 1 | 43 | 2 (0)| 00:00:01 |
|* 7 | INDEX RANGE SCAN | SYS_C006701 | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
5 - filter("SYS_NC_TYPEID$" IS NOT NULL)
6 - access("SYS_NTpzENS1H/RwSSC7TVzvlqmQ=="."NESTED_TABLE_ID"="SYS_NTnN5b8Q+8Txi9V
w5Ysl6x9w=="."SYS_NC0000600007$")
filter("SYS_NC_TYPEID$" IS NOT NULL AND
"NESTED_TABLE_ID"="CUST_ORDER_TBL"."SYS_NC0000900010$")
7 - access("SYS_NTpzENS1H/RwSSC7TVzvlqmQ=="."NESTED_TABLE_ID"="SYS_NTnN5b8Q+8Txi9V
w5Ysl6x9w=="."SYS_NC0000600007$")
Note
- dynamic sampling used for this statement-----
-- CLEAN UP
DROP TABLE CUST_ORDER_TBL purge;
exec dbms_xmlschema.deleteschema('http://xmlns.example.org/xsd/testcase.xsd'); -
I have to use XML in PL/SQL
Hi all,
I would like to know how to use XML in PL/sql. I would like to know how to go about it. I have installed Oracle 9i and what should I do next. I could not find any step by step documentation.
Please any help is appreciated.
Thanks
Kalpana.KThe following documentation on Oracle XML DB would be useful:
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96620/toc.htm
And this one about Oracle XDK for PL/SQL:
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96621/partpg5.htm#435787 -
How to generate XML file from SQL file !
I am new to XML publisher. I known one way to generate XML file is register one report file in concurrent manager.
But I want to generate XML file from sql file.
Could someone show me how to code in sql file, how to register is in concurrent manager.
Thanks !Hi
Phew ... not sure we have the space here. So I can point you in the right direction:
1. XML data generation - there are two packages in the db you can use with a plsql procedure, XMLGEN and SQL XML. You can also use java APIs too. Try checking the db documentation and search for the above methods.
2. Registering the report - the system administrators guide will provide this info. Hooking the program up with XMLP is covered here - http://www.oracle.com/technology/products/applications/publishing/resource/CM%20Whitepaper5.0.pdf
Regards, Tim
Maybe you are looking for
-
MDX query Help - filtering Measures based on values in a dimension.
Hi, I want to get values of a aggregate measure filtered by value available in Dimension attribute. Details: We have a Measure called "Average Compliance" which provides an average value over certain dimensions. Now I have some target values availabl
-
User entered text at the bottom of my report
Hi SDN I Need user entered text at the intial variable screen should come in my out put of the report as comment at the bottom Thanks, Chinna.
-
Has there been any indication that a Service Pack 3 will be released?
There have been a number of cumulative updates. In the past, there was some caution expressed regarding not applying CUs unless there was a specific issue that the CU addressed. It has been a year since the last Service Pack. The CUs have included qu
-
Clean Access Agent 4.0.5 certificate issue
Dear all, I ran into an issue that I hope you could help me resolve. We have NAC 4.0.5 and windows active directory domain.... the clients log on to the client to access the network with their domain credentials and they used to get the "Certificate
-
How do I create a print range: in Numbers
I wish to highlight a number of cells from an accounts document for printing those cell only I do not wish to print the whole doucment and show all accounts information. ( Appleworks had this useful function ) Many thanks