ExtractValue and witespace
Hello!
I have an xml like this:
<file>
<fieldend>'||chr(13)||chr(10)||'</fieldend>
</file>and when i select it:
select '"'||ExtractValue(XMLType('<file><fieldend>'||chr(13)||chr(10)||'</fieldend></file>'),
'file/fieldend/text()')||'"' "fieldend"
into sFieldEnd
from duali have just:
""I run it in pl/sql procedure and select it into the string variable, i expect in my string chr(13)||(10).
How can i get in sFieldEnd value chr(13)||chr(10) ?
Why not do something like
declare
v_mystring varchar2(4000);
sFieldEnd varchar2(4000);
begin
v_mystring := ' ''||chr(13)||chr(10)||'' ';
sFieldEnd := v_mystring;
execute immediate ....etc etc etc
end;
/(pseudo code)
Similar Messages
-
Select / extractValue and Datatype
Database: Oracle 9.2.0.1.0
I am selecting from "XML Schema Validating" data stored in column of XMLTYPE datatype.
SELECT
extractvalue(value(t), '/path1/element1') DateVal1,
extractvalue(value(t), '/path1/element2/@attribute') Date2
FROM XML_TABLE A,
TABLE (
xmlsequence (extract(A.XML_COLUMN,'path0/path1'))) t;
Returned values DateVal1, Date2 are strings and not of date datatype. Registered schema for the above element and attribute is of date datatype. How can I retain datatype in my select statement?
Any additional input will be appreciated.Please see thread at
any relationship between extractvalue's return type and sqltype? -
XML extractvalue and NULL result-Problem
I've got a very strange problem: One select gets restults in my development-database, the same select in production retrieves NULL.
The following sql-construct:
SELECT (
CASE
WHEN personkey!=-1
THEN
( SELECT extractvalue( v.xml, '/p:PersonData/p:TypedPostalAddress[@id="' ||<string> || '"]/p:PostalAddress/p:PostalCode', .....')
FROM <tbl1>,<tbl2>
WHERE tbl1.id=tbl2.id)
ELSE
( SELECT 'no person' FROM dual )
END ) adress,
FROM <tbl3>
WHERE <tbl3>.personkey!=-1
When I use a view containing an outer join in the ELSE-Condition of the case I'm not getting a result in production, but I do in development (same data, same oracle-version, but other instance), but when I use a view without an outer join in the else-Condition, I'm getting results also in production. The column "personkey" is not nullable.
Does anyone got an idea what could be wrong with this SQL?
Thanks in advance for help!Additional Information:
When resolving the CASE to a "union all" query, I am having the following result:
query1 is working
query2 is working
joining both queries with union all => the result of the first query (with the extractvalue) is NULL, the second query is still working. -
Which is better: extractValue or existsNode for Performance
Hi,
We have XMLDB Table with only 1 Column (XMLType) created using below:
create table TNMAB_AGREEMENT_XML( AGREEMENT_XML XMLType )
XMLTYPE COLUMN AGREEMENT_XML XMLSCHEMA "ABQuote_V1.xsd" ELEMENT "Quote"
VARRAY AGREEMENT_XML.XMLDATA."SHIPPING_PARTIES"
STORE AS TABLE SHIPPING_PARTIES_NT
((PRIMARY KEY (NESTED_TABLE_ID, ARRAY_INDEX) ENABLE))
VARRAY AGREEMENT_XML.XMLDATA."SALES_OFFICE_CODES"."STRING_WRAPPERS"
STORE AS TABLE SALES_OFFICE_CODES_NT
((PRIMARY KEY (NESTED_TABLE_ID, ARRAY_INDEX) ENABLE))
TABLESPACE RGM_ME_DATA;
alter table TNMAB_AGREEMENT_XML
add constraint TNM_AGREEMENT_XML_PK primary key (AGREEMENT_XML.XMLDATA."AGREEMENT_ID",
AGREEMENT_XML.XMLDATA."AGREEMENT_VERSION")
using index tablespace RGM_ME_INDX;
We populated around 500K rows and have been seeing some Performance Issues
in accessing data from above Table, at times.
What is difference between extractValue and existsNode in terms of performance?
Here are sample queries:
SELECT extract(AGREEMENT_XML, '/') "Quote" FROM TNMAB_AGREEMENT_XML WHERE extractValue(AGREEMENT_XML, '/Quote/Identifier') = ‘00003554’
SELECT extract(AGREEMENT_XML, '/') "Quote" FROM TNMAB_AGREEMENT_XML WHERE existsNode(AGREEMENT_XML, '/Quote[Identifier = "00003554"]') = 1
Which of the above would be better to use existsNode or extractValue.
In above case, both the queries are expected to return Single Row (searched
using Quote Identifier, which is defined as PK of Table) and query explain plan does
show usage of PK for above queries.
Thanks
user641521In theory existsNode can be slightly better, however in you cases the two queries are not identical.
Also there are a number of other issues with your query..
1. extract(AGREEMENT_XML, '/') is not required. You should just have the AGREEMENT_XML column. Extract is only need when extracting a fragment from the XML. Since you are returning the entire document the use of extract(column,'/') is redundant, but can cause performance issues..
THis query should be written as
SELECT AGREEMENT_XML "Quote"
FROM TNMAB_AGREEMENT_XML
WHERE extractValue(AGREEMENT_XML, '/Quote/Identifier') = ‘00003554’
and can be written using existsNode as
SELECT AGREEMENT_XML "Quote"
FROM TNMAB_AGREEMENT_XML
WHERE existsNode(AGREEMENT_XML, '/Quote[Identifier="00003554"]') = 1
Assuming Identifier can only occur once inside Quote. If Identifier can occur multiple times inside Quote then the existsNode version would still work while the extractValue version would return errors -
ExtractValue-namespace problem?
hi
extract(value(x),'//owl:Ontology') extracts the node, but the result of
extractValue(value(x),'//owl:Ontology//rdfs:label') is empty. I tried different way but without any success.
Any idea what can be the problem?
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:owl="http://www.w3.org/2002/07/owl#">
<owl:Ontology>
<rdfs:comment>An example OWL ontology</rdfs:comment>
<rdfs:comment>Derived from the DAML Wine ontology at
http://ontolingua.stanford.edu/doc/chimaera/ontologies/wines.daml
Substantially changed, in particular the Region based relations.
</rdfs:comment>
<rdfs:label>Wine Ontology</rdfs:label>
</owl:Ontology>
</rdf:RDF>Problem solved.
Thanks,
See: Re: extractvalue and Xpath -
How to get a value from Specific XML Node
Hi all,
I'm just trying to introduce to XMLType and see the potencialities of that.
DB version:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for IBM/AIX RISC System/6000: Version 10.2.0.5.0 - Productio
NLSRTL Version 10.2.0.5.0 - Production
I'm a table with just one CLOB field:
CREATE TABLE asm_test
(doc XMLType NOT NULL)
XMLTYPE doc STORE AS CLOB;
Then i've inserted the following XML data:
<?xml version="1.0" encoding="UTF-8" ?>
- <ReceiptDesc>
<appt_nbr>2142473</appt_nbr>
- <Receipt>
<dc_dest_id>401</dc_dest_id>
<po_nbr>2142473</po_nbr>
<document_type>P</document_type>
<asn_nbr />
- <ReceiptDtl>
<item_id>509720</item_id>
<unit_qty>83.0000</unit_qty>
<receipt_xactn_type>R</receipt_xactn_type>
+ <receipt_date>
<year>2012</year>
<month>09</month>
<day>17</day>
<hour>15</hour>
<minute>33</minute>
<second>49</second>
</receipt_date>
<receipt_nbr>6902340</receipt_nbr>
<container_id>1</container_id>
<to_disposition>ATS</to_disposition>
<user_id>NTCPO01</user_id>
<catch_weight />
</ReceiptDtl>
- <ReceiptDtl>
<item_id>509740</item_id>
<unit_qty>17.0000</unit_qty>
<receipt_xactn_type>R</receipt_xactn_type>
+ <receipt_date>
<year>2012</year>
<month>09</month>
<day>17</day>
<hour>15</hour>
<minute>33</minute>
<second>49</second>
</receipt_date>
<receipt_nbr>6902344</receipt_nbr>
<container_id>1</container_id>
<to_disposition>ATS</to_disposition>
<user_id>NTCPO01</user_id>
<catch_weight />
</ReceiptDtl>
</Receipt>
</ReceiptDesc>
And then i have started to make some tests to retrieve data from.
SELECT EXTRACTVALUE(doc, '/ReceiptDesc/appt_nbr') FROM asm_test; -- got the correct value 2142473
SELECT EXTRACTVALUE(doc, '/ReceiptDesc/Receipt/dc_dest_id') FROM asm_test; ---- got the correct value 401
select count(*) from asm_jam_test d where (d.doc.getClobVal()) like '%NTCPO01%'; -- got 1
But i need to find a Specific data from XML (the main goal is to update a value inside XML).
If i try this:
select extract(doc, '/ReceiptDesc/Receipt/ReceiptDtl/item_id/text()').getstringVal() from asm_test
where existsNode(doc,'/ReceiptDesc/Receipt/ReceiptDtl/receipt_nbr') = 1;
got: 509720509740 -- which are the concatenate of 2 Item_ids
when i try to find out the Item_id of specific receipt_nbr i got a NULL response.
select extract(doc, '/ReceiptDesc/Receipt/ReceiptDtl/item_id/text()').getstringVal()
from asm_test
where existsNode(doc,'/ReceiptDesc/Receipt/ReceiptDtl/receipt_nbr') = 1 and
extract(doc,'/ReceiptDesc/Receipt/ReceiptDtl/receipt_nbr/text()').getstringVal() = '6902340';
What i'm doing wrong or which is the best way to get data from XML?
Many thanks in advanceHi,
Thanks for providing db version and sample data in the first place.
Don't forget to use the {code} tags to preserve formatting.
Also, when posting XML, do not copy/paste directly from your browser as it retains +/- signs and therefore needs extra processing on our side.
select count(*) from asm_jam_test d where (d.doc.getClobVal()) like '%NTCPO01%'; -- got 1No, don't do it like that.
Use existsNode() function in this situation :
SQL> select count(*)
2 from asm_test
3 where existsNode(doc, '/ReceiptDesc/Receipt/ReceiptDtl[user_id="NTCPO01"]') = 1
4 ;
COUNT(*)
1
when i try to find out the Item_id of specific receipt_nbr i got a NULL response.Yes, that's because this :
extract(doc,'/ReceiptDesc/Receipt/ReceiptDtl/receipt_nbr/text()').getstringVal()returns :
69023406902344So obviously it cannot be equal to '6902340'.
When you have to deal with repeating nodes individually, use XMLTable function to break the structure into relational rows and columns.
The resultset you'll get acts as a virtual table (or inline view) you can then manipulate with SQL operations :
SQL> select x.*
2 from asm_test t
3 , xmltable(
4 '/ReceiptDesc/Receipt/ReceiptDtl'
5 passing t.doc
6 columns item_id varchar2(15) path 'item_id'
7 , receipt_nbr varchar2(15) path 'receipt_nbr'
8 ) x
9 ;
ITEM_ID RECEIPT_NBR
509720 6902340
509740 6902344
Now, you can just add a WHERE clause to filter the RECEIPT_NBR you require :
SQL> select x.item_id
2 from asm_test t
3 , xmltable(
4 '/ReceiptDesc/Receipt/ReceiptDtl'
5 passing t.doc
6 columns item_id varchar2(15) path 'item_id'
7 , receipt_nbr varchar2(15) path 'receipt_nbr'
8 ) x
9 where x.receipt_nbr = '6902340'
10 ;
ITEM_ID
509720
That can also be achieved with EXTRACTVALUE and a single XPath expression (assuming RECEIPT_NBR is unique) :
SQL> select extractvalue(
2 doc
3 , '/ReceiptDesc/Receipt/ReceiptDtl[receipt_nbr="6902340"]/item_id'
4 ) as item_id
5 from asm_test
6 ;
ITEM_ID
509720 -
Hi All,
I am trying to insert data into oracle 9i temp tables using the following style. but getting error as
ERROR at line 3
ORA-00933 SQL command not properly ended
Please assist me.
INSERT INTO emp (empname,empno)
SELECT *
FROM XMLTABLE (
'/EMP/CODE'
PASSING xmltype (BFILENAME ('test_dir', 'emp.xml'), NLS_CHARSET_ID ('CHAR_CS'))
COLUMNS empname VARCHAR (30) path 'empname',
empno VARCHAR (30) path 'empno')
MY emp.xml is
<?xml version="1.0" encoding="AR8ISO8859P6"?>
<EMP>
<CODE>
<EMPNAME>YALEXFBARK044</EMPNAME>
<EMPNO>803926354086</EMPNO>
</CODE>
<CODE>
<EMPNAME>YALEXFOLV0044</EMPNAME>
<EMPNO>803926354109</EMPNO>
</CODE>
<CODE>
<EMPNAME>YALEXFREDTT44</EMPNAME>
<EMPNO>803926354093</EMPNO>
</CODE>
<EMP>>
Oracle version: 8i - 9.0.x.x
There was no option that I can recall or could find. All the parsing of XML that I've done in 8i was via the xmldom package.
Oracle version: 9.2.x.x - 10.1.x.x
This is were Oracle introduced extract, extractValue and TABLE(XMLSequence(extract())) for dealing with repeating nodes.
Oracle version: 10.2.x.x
Oracle introduced XMLTable as a replacement for the previous methods since it could handle all three methods for extracting data from XML. At that point, Oracle stopped enhancing extract/extractValue in terms of performance and focused on XMLTable. In 10.2.0.1 and .2, XMLTable was implemented via Java and in .3 it was moved into the kernel so performance from .3 onwards should be better than the older 9.2 / 10.1 methods. If not, feel free to open a ticket with Oracle support. Apparently Oracle also introduced XMLQuery as well but I've never heard of many using that in 10.2
>
from Methods to parse XML per Oracle version
so use correct way for your oracle version -
How do I display result of EXTRACT in PL/SQL
I'm new to Oracle. I've begun experimenting with the XML functions. I was able to test existsNode and extractValue and see my results OK using DBMS_OUTPUT.PUT_LINE(<some variable of type X>) but I'm failing with EXTRACT. I currently think that extract returns an XML fragment of data type XMLType. I've failed to figure out how to display this fragment so see if my extract is doing what I expect. I've tried TO_CHAR(), TO_CLOB, and EXTRACT('/Root/text()').getStringVal() with no success. Could one of you point me in the right direction? My test is below.
DECLARE XMLDoc XMLTYPE;
XMLOut XMLType;
BEGIN
XMLDoc := XMLTYPE('<Root>
<Trans_Info Name="ORIGINAL_AUTH_AMOUNT" Value="100.00" Mod_Date="2005-11-18" Trans_Id="100000" Xi_Id="100"></Trans_Info>
<Trans_Info Name="Web Auth ID" Value="Houston" Mod_Date="2005-11-18" Trans_Id="100000" Xi_Id="100"></Trans_Info>
<Trans_Info Name="3_SHIP_TO_STATE" Value="Of Mind" Mod_Date="2005-07-28" Trans_Id="100000" Xi_Id="100"></Trans_Info>
</Root>');
SELECT EXTRACT(VALUE(x),'/Root')
INTO XMLOut
FROM TABLE(XMLSEQUENCE(XMLDoc.EXTRACT('/Root'))) x;
DBMS_OUTPUT.PUT_LINE(XMLOut);
END;As Garret said getClobVal() should work as should getStringVal()..
You shouldn't be using XMLSEQUENCE on a node that only occurs once in the document (eg the root node). XMLSEQUENCE should be used to generate virtual tables from nodes that occur mutltiple times as the following shows..
SQL> set serveroutput on
SQL> --
SQL> DECLARE
2
3 XMLDoc XMLTYPE;
4 XMLOut XMLType;
5
6 cursor getTransInfo is
7 select value(x) TRANSINFO
8 from table(xmlsequence(extract(XMLDoc,'/Root/Trans_Info'))) x;
9
10 BEGIN
11 XMLDoc := XMLTYPE(
12 '<Root>
13 <Trans_Info Name="ORIGINAL_AUTH_AMOUNT" Value="100.00" Mod_Date="2005-11-18" Trans_Id="100000" Xi_Id="100"></Trans_Info>
14 <Trans_Info Name="Web Auth ID" Value="Houston" Mod_Date="2005-11-18" Trans_Id="100000" Xi_Id="100"></Trans_Info>
15 <Trans_Info Name="3_SHIP_TO_STATE" Value="Of Mind" Mod_Date="2005-07-28" Trans_Id="100000" Xi_Id="100"></Trans_Info>
16 </Root>');
17
18 -- Can use an in-line SELECT INTO here as only one row is returned..
19
20 SELECT EXTRACT(XMLDoc,'/Root')
21 into XMLOUT
22 from dual;
23
24 -- Can also be written as xmlout := XMLDOC.extract('/Root');
25
26 -- Use getStringVal() or getClobVal() to serialize XMLType for DBMS_OUTPUT.
27
28 DBMS_OUTPUT.PUT_LINE('extract(''/Root'') : ');
29 DBMS_OUTPUT.NEW_LINE();
30 DBMS_OUTPUT.PUT_LINE(XMLOut.getStringVal());
31 DBMS_OUTPUT.NEW_LINE();
32
33 -- Use the Cursor to process the set of Trans_Info nodes. Cannot use an inline SELECT INTO here as multiple rows are returned.
34
35 DBMS_OUTPUT.PUT_LINE('value(x) : ');
36 DBMS_OUTPUT.NEW_LINE();
37
38 for r in getTransInfo loop
39 DBMS_OUTPUT.put_line(r.TRANSINFO.getStringVal());
40 end loop;
41 END;
42
43 /
extract('/Root') :
<Root><Trans_Info Name="ORIGINAL_AUTH_AMOUNT" Value="100.00"
Mod_Date="2005-11-18" Trans_Id="100000" Xi_Id="100"/><Trans_Info Name="Web Auth
ID" Value="Houston" Mod_Date="2005-11-18" Trans_Id="100000"
Xi_Id="100"/><Trans_Info Name="3_SHIP_TO_STATE" Value="Of Mind"
Mod_Date="2005-07-28" Trans_Id="100000" Xi_Id="100"/></Root>
value(x) :
<Trans_Info Name="ORIGINAL_AUTH_AMOUNT" Value="100.00" Mod_Date="2005-11-18"
Trans_Id="100000" Xi_Id="100"/>
<Trans_Info Name="Web Auth ID" Value="Houston" Mod_Date="2005-11-18"
Trans_Id="100000" Xi_Id="100"/>
<Trans_Info Name="3_SHIP_TO_STATE" Value="Of Mind" Mod_Date="2005-07-28"
Trans_Id="100000" Xi_Id="100"/>
PL/SQL procedure successfully completed.
SQL> -
I created a view for XMLType table. When I insert rows into table they are not reflected in view.
CREATE TABLE EMPLOYEE OF XMLType
XMLTYPE store AS OBJECT RELATIONAL
XMLSCHEMA "EMPLOYEE.XSD" ELEMENT "root";
CREATE OR REPLACE VIEW
employee_master_view(empid, empname, empproj, emporg)
AS SELECT extractValue(OBJECT_VALUE, '/EMPLOYEE/empid'),
extractValue(OBJECT_VALUE, '/EMPLOYEE/empname'),
extractValue(OBJECT_VALUE, '/EMPLOYEE/empproj'),
extractValue(OBJECT_VALUE, '/EMPLOYEE/emporg')
FROM EMPLOYEE;
INSERT INTO EMPLOYEE VALUES (XMLType(bfilename('XML_DIR', 'EMPLOYEE.XML'),
nls_charset_id('AL32UTF8')));
SELECT object_value from employee;
OBJECT_VALUE
SYS.XMLTYPE
SELECT extract (object_value, '/') from employee;
EXTRACT(OBJECT_VALUE,'/')
<root><empid>1</empid><empname>Gates</empname><empproj>EIS</empproj><emporg>Tata Cosultancy Services</emporg></root>
1 rows selected
desc employee_master_view;
Name
Null
Type
EMPID
VARCHAR2()
EMPNAME
VARCHAR2()
EMPPROJ
VARCHAR2()
EMPORG
VARCHAR2()
4 rows selected
select empid, empname, empproj, emporg from employee_master_view;
EMPID EMPNAME EMPPROJ EMPORG
1 rows selected
This returns empty rows. It should be printing the values of the xml tags in the columns.
Please help.extractValue(OBJECT_VALUE, '/EMPLOYEE/empid'),
I don't see any "EMPLOYEE" element in your sample XML document. Do you?
Try this XPath instead : /root/empid
And be aware extractValue and alike are deprecated starting from 11.2. -
Hello,
i have a field which stores IP and Domain data in XML format. The field data type is BLOB.
here is the XML data sample stored in the field.
<?xml version = '1.0' encoding = 'UTF-8'?>
<DOMAIN Name="DOMAIN_NAME HERE">
<IPADDRESS Address="X.X.X.X1"></IPADDRESS>
<IPADDRESS Address="X.X.X.X2"></IPADDRESS>
<IPADDRESS Address="X.X.X.X3"></IPADDRESS>
<IPADDRESS Address="X.X.X.X4"></IPADDRESS>
... ETC
Is it possible to run SELECT against this field and retrieve the data in the table format, so the output will have two fields and look like
domain IPADDRESS
DOMAIN_NAME HERE X.X.X.X1
DOMAIN_NAME HERE X.X.X.X2
DOMAIN_NAME HERE X.X.X.X3
DOMAIN_NAME HERE X.X.X.X4
I have tried many option with Extract, extractvalue and XMLQuery, not luck.
Thank you very much!
SergeiUse the extractValue() function to extract the node values.
Refer example 4-3.
http://www.lc.leidenuniv.nl/awcourse/oracle/appdev.920/a96620/xdb04cre.htm#1024805 -
Help retreiving XML data in table format
Hello,
i have a field which stores IP and Domain data in XML format. The field data type is BLOB.
here is the XML data sample stored in the field.
<?xml version = '1.0' encoding = 'UTF-8'?>
<DOMAIN Name="DOMAIN_NAME HERE">
<IPADDRESS Address="X.X.X.X1"></IPADDRESS>
<IPADDRESS Address="X.X.X.X2"></IPADDRESS>
<IPADDRESS Address="X.X.X.X3"></IPADDRESS>
<IPADDRESS Address="X.X.X.X4"></IPADDRESS>
... ETC
Is it possible to run SELECT against this field and retrieve the data in the table format, so the output will have two fields and look like
domain IPADDRESS
DOMAIN_NAME HERE X.X.X.X1
DOMAIN_NAME HERE X.X.X.X2
DOMAIN_NAME HERE X.X.X.X3
DOMAIN_NAME HERE X.X.X.X4
I have tried many option with Extract, extractvalue and XMLQuery, not luck.
Thank you very much!
SergeiTry...
xp20:format-dateTime(string($dateFromDatabase), '[D01]-[MN,*-3]-[Y0001] [H01]:[m01] P')Ref
http://www.w3.org/TR/xslt20/#function-format-dateTime
Cheers,
Vlad -
Hi All,
Please can you give an idea how to fech xml data..I wanto fetch all <POL_NO> tag data in a temp table.
My sample xml:
<POL>
<Polinfo>
<POL_NAME>COMP1</POL_NAME>
<POL_NO>100</POL_NO>
</Polinfo>
</POL>
<POL>
<Polinfo>
<POL_NAME>COMP2</POL_NAME>
<POL_NO>101</POL_NO>
</Polinfo>
</POL>
<POL>
<Polinfo>
<POL_NAME>COMP3</POL_NAME>
<POL_NO>102</POL_NO>
</Polinfo>
</POL>
<POL>
<Polinfo>
<POL_NAME>COMP4</POL_NAME>
<POL_NO>103</POL_NO>
</Polinfo>
</POL>
Thanks,The EXTRACTVALUE and XMLSEQUENCE method is deprecated in 11g, and from 10g you would be better using the XMLTABLE method:
SQL> ed
Wrote file afiedt.buf
1 with t as (select xmltype('<root>
2 <POL>
3 <Polinfo>
4 <POL_NAME>COMP1</POL_NAME>
5 <POL_NO>100</POL_NO>
6 </Polinfo>
7 </POL>
8 <POL>
9 <Polinfo>
10 <POL_NAME>COMP2</POL_NAME>
11 <POL_NO>101</POL_NO>
12 </Polinfo>
13 </POL>
14 <POL>
15 <Polinfo>
16 <POL_NAME>COMP3</POL_NAME>
17 <POL_NO>102</POL_NO>
18 </Polinfo>
19 </POL>
20 <POL>
21 <Polinfo>
22 <POL_NAME>COMP4</POL_NAME>
23 <POL_NO>103</POL_NO>
24 </Polinfo>
25 </POL>
26 </root>') as xml from dual)
27 --
28 -- end of test data
29 --
30 select x.*
31 from t
32 ,xmltable('/root/POL'
33 passing t.xml
34 columns pol_name varchar2(10) path './Polinfo/POL_NAME'
35 ,pol_no number path './Polinfo/POL_NO'
36* ) x
SQL> /
POL_NAME POL_NO
COMP1 100
COMP2 101
COMP3 102
COMP4 103 -
Migrating V9 to V10: Update XML Fragment CLOB does not work anymore
I have an XML Schema that contains an element, named Operazione, mapped to a CLOB.
I just migrate to Oracle 10.1.0.2.0 from version 9.2.0.2.0 and the code I developed does not work anymore.
To get a CLOB on v 9.2.0.2.0 I issued the following statement:
select extractValue(value(p),'/operazione.log/Operazione') from XMT_OPERAZIONE_LOG p
where existsNode(value(p),'/operazione.log/Journal[NumeroElettronico=1234567890]') = 1
To make it working on V10 I have to change it as follow:
select extract(value(p),'/operazione.log/Operazione').getClobVal() from XMT_OPERAZIONE_LOG p
where existsNode(value(p),'/operazione.log/Journal[NumeroElettronico=1234567890]') = 1
So using extract intead of extractValue and adding getClobVal() I was able to read the CLOB.
The problem that I was not able to solve is related to CLOB update. In V9 just adding the âfor updateâ clause I was able to change the CLOB value on DB.
In V10 if I run the V9 statement I get the error:
ORA-03113: end-of-file on communication channel
If I use the statement modified for V10, adding the âfor updateâ clause, I get the CLOB and I can change the CLOB value but nothing goes on the DB. Probably I am working on a copy of the DB CLOB.
If I remove the getClobVal() I get an OPAQUE type that I can use on a XMLType but, still, nothing is stored on DB.
Any suggestion ?
I tried with both OCI and Thin ClientCan anybody help me ?
Is it better to use different strategies ( eg. Stored Procedure, DBMS_XMLSTORE etc, etc. ) ?
Any experience updatating XML Fragment CLOB on Oracle V10 ? -
Help needed!! XML Query-Identical Tag
I have the following xml content in a database field of type XMLTYPE.
Version:
Oracle9i Enterprise Edition Release 9.2.0.5.0
<configuration>
<atm>
<arg1>10</arg1>
<arg2>100</arg2>
<val>Q1</val>
<pack>
<arg1>256</arg1>
</pack>
</atm>
<atm>
<arg1>20</arg1>
<arg2>200</arg2>
<val>Q2</val>
<pack>
<arg1>1024</arg1>
</pack>
</atm>
</configuration>
How do I get the value "1024" from an identical tag "atm" using xpath query ?
To be specific:
select second-atm/pack/arg1.value from xml where second-atm.arg1.value=20
I am new to extractvalue and existsnode functions.
Any help is appreciated!Thanks Sundar.
Got the reply from another member.
His Response follows
with qry as (
select '<configuration>
<atm>
<arg1>10</arg1>
<arg2>100</arg2>
<val>Q1</val>
<pack>
<arg1>256</arg1>
</pack>
</atm>
<atm>
<arg1>20</arg1>
<arg2>200</arg2>
<val>Q2</val>
<pack>
<arg1>1024</arg1>
</pack>
</atm>
</configuration>' xml from dual)
select XMLTYPE(xml).extract('/configuration/atm[position() = 2 and arg1="20"]/pack/arg1/text()') data from qry ; -
Getting xml data into Oracle 9.2
Hi
URGENT! NEED HELP ASAP PLEASE!
I have an unique situation.
Iam getting large data in XML wrapper.The XML file has all sort of data in it
1. Multi-delimited text data in CData section
e.x H3005234 John Koenig 123 Street
H4004567 99999999 $1000.00 $200.00
2. Formatted text data in CData section which I need to preserve
I need to Take each of this data section and write it to individual normalized database columns
Iam thinking of taking the following approach
Use XMLDB and PL/SQL to parse the data and do data transofrmations
Iam having the following problems
1. The Multi-delimited data in CData section when i create a .xsd file is treated as text.Iam worried that since this is a multi-delimited fixed width file having white spaces .will the white spaces be eliminated while storage if so how would i parse the data to know which data belwongs to what section or record
2. How do i register the schema so that i can use the best approach to solve the issues
Please help
Thankyou
Seshadri
[email protected]
thx>
Oracle version: 8i - 9.0.x.x
There was no option that I can recall or could find. All the parsing of XML that I've done in 8i was via the xmldom package.
Oracle version: 9.2.x.x - 10.1.x.x
This is were Oracle introduced extract, extractValue and TABLE(XMLSequence(extract())) for dealing with repeating nodes.
Oracle version: 10.2.x.x
Oracle introduced XMLTable as a replacement for the previous methods since it could handle all three methods for extracting data from XML. At that point, Oracle stopped enhancing extract/extractValue in terms of performance and focused on XMLTable. In 10.2.0.1 and .2, XMLTable was implemented via Java and in .3 it was moved into the kernel so performance from .3 onwards should be better than the older 9.2 / 10.1 methods. If not, feel free to open a ticket with Oracle support. Apparently Oracle also introduced XMLQuery as well but I've never heard of many using that in 10.2
>
from Methods to parse XML per Oracle version
so use correct way for your oracle version
Maybe you are looking for
-
Setting up a domain using Oracle DB.
I creating a domain manually applying portal template using our own WLST script. We successfully applied workshop extension but whenever we try to apply the personalization extension we go the following exception: WARNING] com.bea.plateng.domain.scri
-
HCM P&F - Attachment section is NOT visible for the approver
Hi Attachment possible in the process but after submission (with attachment), when approver opens the process, attachment section is not visible to them. We are using FPM forms. Appreciate your inputs. Thanks
-
How to define script object for plug-in
hi all, I'm new developer in InDesign Server. I'm having a look at the SnipRunner & BasicPersistInterface. In the file SnippetRunner.jsx: // get the SDKCodeSnippetRunner object var snippetRunner = app.sdkCodeSnippetRunnerObject; In the file BasisPers
-
HT4014 when you update to 10.6.3 will you loose your files and pictures?
when you update to 10.6.3 will you loose your files and pictures?
-
I am trying to attach to my e-mail a document. When I select the document, I am sent back to the original e-mail with no attachments attached. Am using Firefox 8.0.1 an a Mac OS X 10.7.2.