oracle - ORA-31011 on XMLTYPE column -


i'm using oracle version - 11.2.0.4

i've reproduced problem i'm facing in more simplified manner below. i've 2 tables xmltype column. table 1 (base_table in example below) has storage model xmltype binary xml. table 2 (my_tab) has storage model xmltype clob.

with xml in base_table i'm extracting value of attribute based on condition. attribute in turn name of node in xml contained in my_tab , want extract node's value my_tab. please note not have liberty change logic @ moment.

code working fine till storage model xmltype column clob in both tables. base_table recreated (drop , create), it's storage model got modified binary xml understand that's default storage model in version 11.2.0.4

here create table stmt , sample data -

create table base_table(xml xmltype); create table my_tab(xml xmltype) xmltype column "xml" store clob;  insert base_table(xml) values (xmltype('<root>   <element name="nodea">     <node1>a-node1</node1>     <node2>a-node2</node2>   </element>   <element name="nodeb">     <node1>b-node1</node1>     <node2>b-node2</node2>   </element>   <element name="nodec">     <node1>c-node1</node1>     <node2>c-node2</node2>   </element> </root>') );  insert my_tab(xml) values (xmltype('<test_xml>   <some_node>     <xyz>       <nodeb>my area of concern</nodeb>       <other_node> irrelevant </other_node>     </xyz>   </some_node>   <some_other_node>     <abc> value node </abc>   </some_other_node> </test_xml>') ); 

below query fails:

select extract(t.xml, sd.tag_name).getstringval() (select '//' || extract(value(d), '//@name').getstringval() || '/text()' tag_name         base_table b,              table(xmlsequence(extract(b.xml, '//root/element'))) d        extract(value(d), '//node2/text()').getstringval() = 'b-node2') sd, my_tab t;  ora-31011: xml parsing failed  ora-19202: error occurred in xml processing  lpx-00601: invalid token in: '///text()'  

however, query works fine , able extract value of node i'm interested in. can seen tag_name fetched required, when used within "extract", it's value somehow lost.

select sd.tag_name, extract(t.xml, '//nodeb/text()').getstringval() (select '//' || extract(value(d), '//@name').getstringval() || '/text()' tag_name         base_table b,              table(xmlsequence(extract(b.xml, '//root/element'))) d        extract(value(d), '//node2/text()').getstringval() = 'b-node2') sd, my_tab t; 

if change xmltype storage model of base_table clob, erroneous query works fine again.

i understand what's going wrong storage model binary xml.

i modified query below, working fine. i.e. convert clob , xmltype:

select extract(t.xml, sd.tag_name).getstringval()  (select '//' || extract(value(d), '//@name').getstringval() || '/text()' tag_name   base_table b,   table(xmlsequence(extract(xmltype(b.xml.getclobval()), '//root/element'))) d   extract(value(d), '//node2/text()').getstringval() = 'b-node2') sd,  my_tab t;  

thanks, kailash


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -