Querying XMLTYPE
Hi,
Below is the xml data inserted into XMLTYPE column. I want to fetch the specific element from Xml for ex: <Name> , tried the below query which didnt work.
SELECT c.customerinfo.extract('//Name/text()').getStringVal() "Name"
FROM cust_order c;
xml:
<?xml version = "1.0" encoding = "UTF-8"?>
<CustomerInfo IntObjectName = "" MessageId = "" MessageType = "" xmlns = "http://www.siebel.com/xml/EDB%20Customer%20Account%20IO" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://www.siebel.com/xml/EDB%20Customer%20Account%20IO CustomerCrea
tion.xsd">
<CreateAccounts>
<Customer>
<Id>Cust1</Id>
<Name>Abcd</Name>
</Customer>
</CreateAccounts>
</CustomerInfo>
Please do help me in writing the correct select query.
thanks in advance.
select xmltype('<?xml version = "1.0" encoding = "UTF-8"?>
<CustomerInfo IntObjectName = "" MessageId = "" MessageType = "" xmlns = "http://www.siebel.com/xml/EDB%20Customer%20Account%20IO" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://www.siebel.com/xml/EDB%20Customer%20Account%20IO CustomerCreation.xsd">
<CreateAccounts>
<Customer>
<Id>Cust1</Id>
<Name>Abcd</Name>
</Customer>
</CreateAccounts>
</CustomerInfo>').extract('//Name/text()', 'xmlns="http://www.siebel.com/xml/EDB%20Customer%20Account%20IO" xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation = "http://www.siebel.com/xml/EDB%20Customer%20Account%20IO CustomerCreation.xsd"').getStringVal() col from dualyou need to mention the name spaces ...
Ravi Kumar
Similar Messages
-
Basic question - querying xmltype column
Hi,
Sorry for the basic question but please could someone paste in a working 'select where' statement which will pick out only those rows containing an element with specified content.
For example, how would I return n complete XML documents as query results for a situation where 'element_1' has text content 'apples'?
This does not seem to work:
SELECT x.xml_body.extract('/root_element/element_1/text()').getStringVal()
FROM xmltable x
WHERE x.xml_body.extract('/root_element/element_1/text()').getStringVal()='apples'Hi Paul,
The query you have given works. I tried that query in the following format and it works.
Query 1:
SELECT x.xmlcol.extract(/Employee/Name/text()').getStringVal()
FROM table_name x
WHERE x.xmlcol.extract('/Employee/Name/text()').getStringVal()='Anu'
Query 2:
SELECT extractvalue(x.xmlcol,'//Name/text()')
FROM table_name x
WHERE extractvalue(x.xmlcol,'//Name/text()')='Srini'
Both the queries work. The xml is of the following format
<Employee company="Oracle">
<Name>Anu</Name>
<Department>OTN</Department>
<Location>India</Location>
</Employee>
Can you please tell the database version on which you are working?
For more information on XMLType you can refer the XMLDB Samples located at
http://otn.oracle.com/sample_code/tech/xml/xmldb/content.html
You can also refer to the XMLType Sample present at this location
http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/9i_jdbc/content.html#xmltype
to know how to work with XMLType columns.
You can get back to us if you have any more doubts.
Regards,
Anupama Majety -
hello,
does someone has experience with xml queries and database links?
In my experience the statement
SELECT somefunction(xmltype_column) of table@remote_site;
seems not to work in 9i2 because of CLOB restrictions!
It seems that one has to work with different database handles in an application if you have to query columns of type xmltype at remote sites. Of course this has quite an impact on the application design. You cannot use many features that are comfortable with database links.
Does someone know whether it is planned to provide this functionality in a future release or is this a bold restriction?
Does someone know any other way to query xmltype columns at remote sites?
With best regards
InduOnly issue would be large bandwidth consumption. That too depends on the size of your image.
Arnav Sharma | http://arnavsharma.net/ Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading
the thread. -
Read-only view for XMLType data
HI Gentlemen,
When I execute my SQL statement:
select extract(object_value,'/keytabs/keytab/@SN') SN from keytabs
against a schema-based XMLType table from SQL*Plus I get normal response:
EXTRACT(OBJECT_VALUE,'/KEYTABS/KEYTAB/@SN')
S_KBV_GESCHLECHT
S_VDX_KONTENART
However, when I create a Fusion application with business components, and a custom view in the Model project with the SQL statement above,
it yields:
oracle.sql.OPAQUE@1623820.
Attribute type is String, and query column is VARCHAR(255). There is no entity because the view is read-only.
Can anyone help me how to directly query XMLType to display the contents?
Thanks, regards
Miklos HERBOLYCan you try:
select cast(extract(object_value, '/keytabs/keytab/@SN') as varchar2(255)) SN
from keytabsJohn -
XMLDB performance issues in 9i
We are having very poor performance from query XMLTypes from a 45K schema in 9i. The same extraction procedure works fine in 10g. Unfortunately we are a big company and are standardized on 9i. We installed the latest patchset but this only helped marginally. Does anyone have any suggestions as to how we can fix this in 9i? We are really in a rut with this one.
Please post more details on the query and the xml schema.. Unfortuantely there are a number of performance improvements in 10g which simply cannot be backported to 9i (without the aid of a magic marker). One of which comes to mind is queries involving enumerations.
-
dose oracle xe support xquery? and oracle database standard edition?
i want to use oracle xe query xmltype data,what should i do?As I understand it, the XQuery language itself can return any node or fragment. What I was trying to say is that the XQuery function doesn't appear to be able to return COLUMN representations of the Xquery output: you have to have to use the XMLTABLE (not supported in current version of XE) or XMLSEQUENCE (deprecated in 11gR2) in order to query XML like a table.
If you can provide an example where we can do a select col1, col2...from {an XML string} where something=whatever, then I'd love to see it!
with xml as
SELECT XMLQuery('/rowset/row'
PASSING xmltype.createxml('<rowset>
<row><col1>Hello</col1><col2>World</col2></row>
<row><col1>Hello</col1><col2>Again</col2></row>
</rowset>
RETURNING CONTENT) as xml
FROM dual)
select xmlcast(xmlquery('$x/row/col1' passing xml as "x" returning content) as varchar2(30)) as col1,
xmlcast(xmlquery('$x/row/col2' passing xml as "x" returning content) as varchar2(30)) as col2
from xml;
COL1 COL2
HelloHello WorldAgain
hmm, not what I wanted.
I wanted:
COL1 COL2
Hello World
Hello AgainThanks....
Edited by: user6246156 on Mar 23, 2011 8:53 AM -
XMLQuery SQL Error: ORA-00600: internal error code,
Hi guys,
I am trying to use XML feature of Oracle DB. What I am trying to implement is having XMLTYpe field in table and have some values in it and then query that table using XMLQuery(...). I started with example here : http://www.psoug.org/reference/xmlquery.html .
I am able to create table, Insert data into table, but when I tried to run SELECT query it does not work
"SELECT person_id, XMLQuery(
'for $i in /PDRecord
where $i /PDName = "Daniel Morgan"
order by $i/PDName
return $i/PDName'
passing by value person_data
RETURNING CONTENT) XMLData
FROM person_data; "
It throws error like
"Error report:
SQL Error: ORA-00600: internal error code, arguments: [qmxqrwRewExpr:1], [], [], [], [], [], [], []
00600. 00000 - "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"
Am I missing any thing? or is my Oracle 10g DB is not compatible with XMLType ?
Please help.Hi Marco,
Thanks for replying.
Oracle Database 10g Release 10.2.0.1.0 - Production. so as per you said it should work. I am sorry for being dumb, but I am not DBA guy. can you tell me how to check if XMLDB is installed properly? how can I look at DBA_REGISTRY and what kind of information I will find under DBA_REGISTRY?
BTW I found another way of querying XMLType columns from here http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96620/xdb04cre.htm which uses extract(), existsNode(), etc.. function to accomplish some of the task. As of now I am still digging in it, so not sure which one will be better to use. I mean the link that I showed on my first thread or the above link.
I am still curious why wouldnt my first thread query work.
Thanks again. -
BinaryXML/securefile encoding using Java
Hey All,
I am trying to save to a BinaryXML column stored as Securefile using the following code fragment, but I get this exception at the last line java.sql.SQLException: ORA-31011: XML parsing failed. This is for an ALLOW NON SCHEMA column (I need the flexibility) over theThin JDBC driver.
BinXMLProcessor proc = BinXMLProcessorFactory.createProcessor();
BLOB blob = BLOB.createTemporary(conn, true, BLOB.DURATION_SESSION);
blob.open(BLOB.MODE_READWRITE);
OutputStream blobOutpStream = blob.setBinaryStream(0L);
BinXMLStream outbin = proc.createBinXMLStream(blob);
BinXMLEncoder enc = outbin.getEncoder();
enc.setProperty(BinXMLEncoder.ENC_SCHEMA_AWARE, false);
enc.setProperty(BinXMLEncoder.ENC_INLINE_TOKEN_DEFS, true);
ContentHandler hdlr = enc.getContentHandler();
XMLReader parser = new SAXParser();
((SAXParser)parser).setValidationMode(SAXParser.NONVALIDATING);
((SAXParser)parser).setContentHandler(hdlr);
parser.parse(new InputSource(new FileReader(inputDoc)));
blobOutpStream.close();
blob.close();
String query = "INSERT INTO testxml(data) VALUES (?)";
OraclePreparedStatement sqlStatement = null;
sqlStatement = (OraclePreparedStatement) conn.prepareStatement(query);
XMLType xmlData = new XMLType(conn, blob, CharacterSet.AL32UTF8_CHARSET);
sqlStatement.setObject(1,xmlData);//blob);
sqlStatement.execute();
When I debug through this code, the blob does not seem be updated after the statement at parser.parse(...). But if I specify a disk file as the argument to createBinXMLStream, that file is updated, but I am not able to read back XML from that file.
I am new to XML programming, and suspect I am not doing some part right. Any idea what is the issue here?
Thanks
AdiClosing
-
Can regular SQL applications such as SQL Navigator, TOAD, SQL PLUS query XMLType data in a tubular view (tables and columns)?
e.g. can we use regular SQL queries to retrieve/update/insert data that are mapped to XMLType using regular SQL applications?Sorry, i don't have the answer, but this is just to enphasize that this is an important question. Please, Oracle Gurus, shed some light to us..!
--jlb -
Help on how to query 11g table with XMLType column
To all,
We have this table:
DESC MESSAGE
Name Null Type
MESSAGE_ID NOT NULL NUMBER(38)
REQUEST_UU_ID NOT NULL VARCHAR2(50)
MESSAGE_TYPE_CD NOT NULL CHAR(3 CHAR)
EMPLOYEE_NUM NOT NULL VARCHAR2(8)
SEQUENCE_NUM VARCHAR2(20)
REVERSAL_SEQUENCE_NUM VARCHAR2(20)
TRANSACTION_TS TIMESTAMP(6)
MESSAGE_CONTENT_TXT NOT NULL XMLTYPE()
CREATE_BY_NM NOT NULL VARCHAR2(50 CHAR)
CREATE_BY_TS NOT NULL TIMESTAMP(6)
LAST_UPDATE_BY_NM NOT NULL VARCHAR2(50 CHAR)
LAST_UPDATE_BY_TS NOT NULL TIMESTAMP(6)
Given we have multiple columns and one is XMLType how do I query to find rows in the db that match this XPath
Here is a fragment of XML that is held in MESSAGE_CONTENT_TXT XMLType column:
<?xml version="1.0" encoding="UTF-8"?>
<cfg-env:Envelope xmlns="http://www.co.com/schemas/CFX/" xmlns:cfg-env="http://www.co.com/schemas/cfg-env/" xmlns:cfg-hdr="http://www.co.com/schemas/cfg-hdr/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.co.com/schemas/cfg-env/" >
<cfg-env:Header>
<cfg-hdr:MessageHeader xmlns:cfg-hdr="http://www.co.com/schemas/cfg-hdr/" xmlns:cfg-env="http://www.co.com/schemas/cfg-env/" xmlns="http://www.co.com/schemas/CFX/">
<cfg-hdr:Service>
<cfg-hdr:ServiceName>process</cfg-hdr:ServiceName>
<cfg-hdr:MessageType>Request</cfg-hdr:MessageType>
<cfg-hdr:ServiceVersion>1</cfg-hdr:ServiceVersion>
</cfg-hdr:Service>
<cfg-hdr:From>
<cfg-hdr:PartyId>13-175-8724</cfg-hdr:PartyId>
<cfg-hdr:CostCenter>2009065</cfg-hdr:CostCenter>
<cfg-hdr:System>
<cfg-hdr:Application>[email protected]</cfg-hdr:Application>
<cfg-hdr:Version>1.0</cfg-hdr:Version>
<cfg-hdr:Channel>TLR</cfg-hdr:Channel>
</cfg-hdr:System>
<cfg-hdr:OrigReplyToQMgr>QMBKRD01</cfg-hdr:OrigReplyToQMgr>
<cfg-hdr:OrigReplyToQ>Q1</cfg-hdr:OrigReplyToQ>
</cfg-hdr:From>
<cfg-hdr:UserSession>
<cfg-hdr:SignonRole>User</cfg-hdr:SignonRole>
<cfg-hdr:LogonId>R099999</cfg-hdr:LogonId>
I'm trying to find rows in the database that are /Envelope/Header/MessageHeader/UserSession/LogonId/R099999.
Thanks for the assistance. I'm new to XML DB. I appreciate the help.
EricHi Eric,
You can use XMLExists, like this :
select *
from message t
where xmlexists(
'declare namespace env = "http://www.co.com/schemas/cfg-env/"; (: :)
declare namespace hdr = "http://www.co.com/schemas/cfg-hdr/"; (: :)
/env:Envelope/env:Header/hdr:MessageHeader/hdr:UserSession[hdr:LogonId=$id]'
passing t.message_content_txt
, 'R099999' as "id"
); -
Query Oracle 9i xmltype tables
Hi,
I have created a table of xmltype and loaded a large xml document of size ~47 MB.
I wish to execute the following query on the table(OracleBench_No_Schema) using Oracle thin driver.
select extract(value(X), '//eNest[@aSixtyFour=2]')
from OracleBench_No_Schema X;
can you provide me with a skeleton code for running such queries using a java program?
thanks in advance.
DayalHi ,
java version 1.4.2
I am using oracle jdbc drivers for java 1.4
I am using the thin driver.
This is the code that I am currently using...
import java.util.Iterator;
import org.w3c.dom.Node;
import java.sql.*;
import java.io.*;
import oracle.xquery.*;
import oracle.xquery.exec.*;
import oracle.xml.parser.v2.*;
import oracle.xdb.XMLType;
import oracle.sql.OPAQUE;
import oracle.xdb.XMLType;
import oracle.jdbc.pool.OracleDataSource;
import oracle.jdbc.OraclePreparedStatement;
import oracle.jdbc.OracleResultSet;
public class OracleXMLTypeQuery
public static void main(String[]args)
String query = "select extract(value(X), '//eNest[@aSixtyFour=2]').getClobVal() \n" +
"from OracleBench_No_Schema X";
try
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@138.87.169.78:1521:itkora2","dmuruku","dmuruku");
OraclePreparedStatement stmt = (OraclePreparedStatement) conn.prepareStatement(query);
System.out.println("Executing Query...");
OracleResultSet orset = (OracleResultSet)stmt.executeQuery();
System.out.println("Query Executed....");
while(orset.next())
oracle.sql.CLOB clob = orset.getCLOB(1);
Reader reader = clob.getCharacterStream();
//----------------These set of lines when included in the program are causing protocol violation---------
StringBuffer clobBuffer = new StringBuffer();
char[] buffer = new char[1024];
int readCount;
while ( (readCount = reader.read(buffer)) != -1)
{ clobBuffer.append(buffer, 0, readCount); }
//This included...protocol violation
conn.close();
catch(Exception ex)
System.out.println(ex.toString());
As I mentioned the lines of code between the two commenting lines when Included in the program are causing a protocol violation.
(java.io.IOException: Protocol Violation).
Is there any other way to read data from a Reader Object into a file or to display it on the console output?
please advise
Thanks
DL -
How to improve performance of a query that is based on an xmltype table
Dear Friends,
I have a query that is pulling records from an xmltype table with 9000 rows and it is running very slow.
I am using XMLTABLE command to retreive the rows. It is taking upto 30 minutes to finish.
Would you be able to suggest how I can make it faster. Thanks.
Below is the query.....
INSERT INTO temp_sap_po_receipt_history_t
(po_number, po_line_number, doc_year,
material_doc, material_doc_item, quantity, sap_ref_doc_no_long,
reference_doc, movement_type_code,
sap_ref_doc_no, posting_date, entry_date, entry_time, hist_type)
SELECT :pin_po_number po_number,
b.po_line_number, b.doc_year,
b.material_doc, b.material_doc_item, b.quantity, b.sap_ref_doc_no_long,
b.reference_doc, b.movement_type_code,
b.sap_ref_doc_no, to_date(b.posting_date,'rrrr-mm-dd'),
to_date(b.entry_date,'rrrr-mm-dd'), b.entry_time, b.hist_type
FROM temp_xml t,
XMLTABLE(XMLNAMESPACES('urn:sap-com:document:sap:rfc:functions' AS "n0"),
'/n0:BAPI_PO_GETDETAIL1Response/POHISTORY/item'
PASSING t.object_value
COLUMNS PO_LINE_NUMBER VARCHAR2(20) PATH 'PO_ITEM',
DOC_YEAR varchar2(4) PATH 'DOC_YEAR',
MATERIAL_DOC varchar2(30) PATH 'MAT_DOC',
MATERIAL_DOC_ITEM VARCHAR2(10) PATH 'MATDOC_ITEM',
QUANTITY NUMBER(20,6) PATH 'QUANTITY',
SAP_REF_DOC_NO_LONG VARCHAR2(20) PATH 'REF_DOC_NO_LONG',
REFERENCE_DOC VARCHAR2(20) PATH 'REF_DOC',
MOVEMENT_TYPE_CODE VARCHAR2(4) PATH 'MOVE_TYPE',
SAP_REF_DOC_NO VARCHAR2(20) PATH 'REF_DOC_NO',
POSTING_DATE VARCHAR2(10) PATH 'PSTNG_DATE',
ENTRY_DATE VARCHAR2(10) PATH 'ENTRY_DATE',
ENTRY_TIME VARCHAR2(8) PATH 'ENTRY_TIME',
HIST_TYPE VARCHAR2(5) PATH 'HIST_TYPE') b;Based on response from mdrake on this thread:
Re: XML file processing into oracle
For large XML's, you can speed up the processing of XMLTABLE by using a registered 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;
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"
SQL> set autotrace on explain
SQL> set pages 60 lines 164 heading on
SQL> col cust_id format a8
SQL> select extract(object_value,'/cust_order/@cust_id') as cust_id
2 ,grp.id as group_id, itm.id as item_id, itm.inm as item_name, itm.qty as item_qty
3 from CUST_ORDER_TBL
4 ,XMLTABLE('/cust_order/group'
5 passing object_value
6 columns id number path '@id'
7 ,item xmltype path 'item'
8 ) grp
9 ,XMLTABLE('/item'
10 passing grp.item
11 columns id number path '@id'
12 ,inm varchar2(30) path '@name'
13 ,qty number path '.'
14 ) itm
15 /
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'); -
apart from XQuery,
i know Oracle provided X-Path based search also.
can anyone direct me what's wrong with the following statement?
it returns "no rows selected".
THX~
e.g.1
select extract(value(it),'/Cap/@ctitle').getStringVal() as CTITLE
from ord_xmltype_tbl,
table (xmlsequence(extract(object_value,'Ordinace/Chapter/Cap'))) it
where contains (object_value,'Commonwealth INPATH (/Ordinance/Chapter/Cap/Section/Content/English)') > 0;
e.g.2
select extract(object_value,'/Ordinance/Chapter/Cap/@ctitle').getStringVal() as CTITLE
from ord_xmltype_tbl,
table (xmlsequence(extract(object_value,'/Ordinace/Chapter/Cap'))) it
where existsnode(object_value,'//English[contains(.,"SHORT TITLE AND APPLICATION")>0]')>0;
e.g.3
select extract(value(it),'/Cap/@ctitle').getStringVal() as CTITLE
from ord_xmltype_tbl,
table (xmlsequence(extract(object_value,'/Ordinace/Chapter/Cap'))) it
where existsnode(object_value,'//English[ora:contains(.,"SHORT TITLE AND APPLICATION")>0]', 'xmlns:ora="http://xmlns.oracle.com/xdb"')>0;
and what index i should create for the xmltype table?
in order to speed up the search?
this is the skeleton of the xmltype table
<Ordinance xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://localhost:8081/public/hkliss/ordinance.xsd">
<Chapter ctitle="致命意外條例" etitle="FATAL ACCIDENTS ORDINANCE" id="22">
<Cap ctitle="致命意外條例" etitle="FATAL ACCIDENTS ORDINANCE" id="22">
<Section ctitle="詳題" etitle="Long title" id="0">
<VersionDate>1997-06-30</VersionDate>
<Content>
<Chinese></Chinese>
<English></English>
</Content>
</Section>
</Cap>
<Cap>....</Cap>
<Cap>....</Cap>
<Cap>....</Cap>
<Cap>....</Cap>
<Cap>....</Cap>
<Cap>....</Cap>
</Chapter>
</Ordinance>
thx, expert~
i'm held up in my project right now~~~(please read a little from the manuals...you have already spend so much time on asking stuff, that if you would have
read manuals, you also would understand the things pointed out to you and it would have given you a faster result...)
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/functions051.htm#i1006712
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/functions048.htm#i1006711
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/functions052.htm#i1131042
The optional namespace_string must resolve to a VARCHAR2 value that specifies a default mapping or namespace mapping for prefixes, which Oracle uses when evaluating the XPath expression(s).
is xmlns:ora="http://xmlns.oracle.com/xdb evaluating your Xpath expression, I don't think so...
If I take your examples shown here (http://forums.oracle.com/forums/message.jspa?messageID=1765571#1765571) as a starting point...
the query:
select extract(value(it),'/Cap/@ctitle').getStringVal() as CTITLE
from ord_xmltype_tbl,
table (xmlsequence(extract(object_value,'/Ordinace/Chapter/Cap'))) it
where existsnode(object_value,'//English[ora:contains(.,"SHORT TITLE AND APPLICATION")>0]', 'xmlns:ora="http://xmlns.oracle.com/xdb"')>0;would resolve in
select extract(value(it),'/Cap/@ctitle').getStringVal() as CTITLE
from ord_xmltype_tbl,
table (xmlsequence(extract(object_value,'/Ordinace/Chapter/Cap', 'xmlns:ora="http://localhost:8081/public/hkliss/ordinance.xsd"'))) it
where existsnode(object_value,'//English[ora:contains(.,"SHORT TITLE AND APPLICATION")>0]', 'xmlns:ora="http://localhost:8081/public/hkliss/ordinance.xsd"')>0;
But I would start with a simple "extract" or "existnode" statement, see if I get data output, and then build my SQL statement from there. -
Query about XMLTYPE column structured storage in Oracle Xml db
Dear All,
DB Version: Oracle 11g (11.2.0.3.0)
I have an table having one column as XMLTYPE with Structured storage.
CREATE TABLE Orders
Order_id NUMBER NOT NULL,
Order_etc VARCHAR2(100),
Order_desc XMLType NOT NULL
XMLTYPE Order_desc STORE AS OBJECT RELATIONAL XMLSCHEMA "http://localhost/public/xsd/order_desc_xsd.xsd" ELEMENT "OrderState";
I have then registered the XSD with XML Db schema which is required for Structured storage.
Before this table creation I had created a table (db_objects) of XMLTYPE and was able to use the below query to check for what all objects the XMLTYPE table got broken into when I registered its XSD.
SELECT column_name,
data_type
FROM user_tab_cols
WHERE table_name = 'DB_OBJECTS';
And used below query to look for data stored in Object-Relational structure for my table (DB_OBJECTS) created with XMLTYPE definition.
SELECT EXTRACTVALUE(xseq.column_value, '/THISROW/OWNER') AS owner
, EXTRACTVALUE(xseq.column_value, '/THISROW/OBJECT_NAME') AS object_name
, EXTRACTVALUE(xseq.column_value, '/THISROW/OBJECT_TYPE') AS object_type
, EXTRACTVALUE(xseq.column_value, '/THISROW/OBJECT_ID') AS object_id
, EXTRACTVALUE(xseq.column_value, '/THISROW/CREATED') AS created
FROM db_objects do
, TABLE(XMLSEQUENCE(EXTRACT(VALUE(do), '/ROWSET/THISROW'))) xseq
WHERE ROWNUM <= 10;
Now could someone let me know, how to find how the column (Order_desc) of XMLTYPE was broken down into further objects just like I did for the Table with XMLTYPE (as shown above)?
Many Thanks.First given that you are on 11.2, ExtractValue is deprecated and the documentation lists three options to use instead. Here is one option (untested)
SELECT owner, object_name, object_type, object_id, created
FROM db_objects do,
XMLTable('/ROWSET/THISROW'
PASSING do.object_value
COLUMNS
-- Set data types accordingly
owner VARCHAR2(20) PATH 'owner',
object_name VARCHAR2(20) PATH 'object_name',
object_type VARCHAR2(20) PATH 'object_type',
object_id VARCHAR2(20) PATH 'object_id',
created VARCHAR2(20) PATH 'created');
Second, why does column order matter? You are storing in an object relational method. As long as the XML is valid per the schema, the Oracle will be able to store the data and later retrieve it as well. How that data is stored is mostly Oracle internals and should not be touched as it can be changed from version to version. You can use schema annotation to control how Oracle maps and stores the XML, but nothing in there specifies column order that I am aware of.
It seems additional details are missing as to what you need the information for so that would help others answer your question. -
ORA-03113 when inserting a CLOB value casted as an XMLType from a SELECT query into a table
I have a table that contains a CLOB column with pseudo-XML in it. I want to keep this data in an XMLType column so that I can leverage some of Oracle's built-in XML features to parse it more easily.
The source table is defined as:
CREATE TABLE "TSS_SRM_CBEBRE_LOGS_V"
( "INCIDENT_ID" NUMBER,
"EVENT_TYPE" VARCHAR2(100 BYTE) NOT NULL ENABLE,
"EVENT_KEY" VARCHAR2(100 BYTE),
"CREATION_DATE" TIMESTAMP (6) NOT NULL ENABLE,
"CREATED_BY" VARCHAR2(100 BYTE) NOT NULL ENABLE,
"LOG_MSG" CLOB);
The target (for testing this problem) table is defined as:
CREATE TABLE "TESTME"
( "LOG_MSG" "XMLTYPE"
My query is:
insert /*+ APPEND */ into testme ("LOG_MSG")
select XMLTYPE.createXML("LOG_MSG") as LOG_MSG from "TSS_SRM_CBEBRE_LOGS_V" b;
In SQL*Developer, my error is: Error report:
SQL Error: No more data to read from socket
In SQL*PLUS and Toad, my error is:
ORA-03113: end-of-file on communication channel
Process ID: 13903
Session ID: 414 Serial number: 32739By pseudo-XML, I mean that it doesn't have the xml root node. The content structure is similar to the following:
<a attr1="1" attr2="2" />
<b attr1="3" attr2="4" />
<c attr1="5">
<e attr1="6" attr2="7" />
<e attr1="8" attr2="9" />
<e attr1="10" attr2="11" />
</c>
<d attr1="12" />
OK. Those are XML fragments then.
I'm surprised you say the query alone works.
We cannot build an XMLType instance using the default constructor or createXML() method when the content is composed of fragments.
AFAIK the only option is to use XMLParse() with CONTENT option :
SQL> select xmltype.createxml(LOG_MSG) from TSS_SRM_CBEBRE_LOGS_V;
ERROR:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00245: extra data after end of document
Error at line 2
ORA-06512: at "SYS.XMLTYPE", line 5
no rows selected
SQL> select xmltype(LOG_MSG) from TSS_SRM_CBEBRE_LOGS_V;
ERROR:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00245: extra data after end of document
Error at line 2
ORA-06512: at "SYS.XMLTYPE", line 272
ORA-06512: at line 1
no rows selected
SQL> select xmlparse(content LOG_MSG) from TSS_SRM_CBEBRE_LOGS_V;
XMLPARSE(CONTENTLOG_MSG)
<a attr1="1" attr2="2" />
<b attr1="3" attr2="4" />
<c attr1="5">
<e attr1="6" a
Anyway, you'll eventually hit this :
SQL> insert into testme (LOG_MSG)
2 select XMLparse(content LOG_MSG)
3 from TSS_SRM_CBEBRE_LOGS_V;
insert into testme (LOG_MSG)
ERROR at line 1:
ORA-19010: Cannot insert XML fragments
Maybe you are looking for
-
How to disable "Double Click on Tab Bar to Open New Tab" feature?
Since I upgraded to FF3 I've noticed this very annoying feature with tabs. If you double-click the 2-3 pixel wide bar just beneath tabs, it opens a new empty tab and sets the focus to that new tab (Which means I then have to go close that tab before
-
Installation from 10.6.8 - unable to select HD to install Yosemite
Hi all, I have an old MacBook6,1 of 2009 (the white one), with a 2.26GHz Intel Core 2 Duo processor, 2GB 1067 MHz DDR3 memory, 250GB of storage capability (100GB free), currently running Snow Leopard 10.6.8. I'm trying to upgrade to Yosemite 10.10 (m
-
Missing worksheet when opening in EXCEL 2013
Hi, I had an output from our existing ERP system with file type as XLS. Currently, if open in EXCEL 2010, I am able to view the workbook with multiple sheet. However, now, in EXCEL 2013, I cannot geth the same result. I get only to view 1 sheet with
-
Issues Downloading App Updates
Not quite sure what this means but it will not go away. I've closed iTunes, restarted my computer, and shut down apps that are running in the background. I'm out of options with my limit in knowledge. Below is a screen shot of the message that keeps
-
How to show icons startup manager
Hi ! I'm gooing to try a multi boot hard drive. There is a Mac OS X 10.5 boot, a Mac OS X 10.6 boot, a Mac OS X 10.7 boot and an OS X 10.8 boot. For 10.5 and 10.6 Boot the volumes icons are showed, but not for 10.7 and 10.8. I have just do apple-c /