Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XMLSequence and extract attribute

fcjunicMar 30 2011 — edited Mar 30 2011
Hi all,

From this XML :
<execute-transaction app-ref="SRSRSimpleMult" app-sn="458" login="CARNI">
	<context key="Env:LOGIN" value="CARNI"/>
	<context key="Env:APP_SN" value="458"/>
	<context key="Env:APP_REF" value="SRSRSimpleMult"/>
</execute-transaction>
I would like to extract all the "key" attribute...

The following select returns the good result but all is in 1 row :
select extract(XMLTYPE('<execute-transaction app-ref="SRSRSimpleMult" app-sn="458" login="CARNI">
	<context key="Env:LOGIN" value="CARNI"/>
	<context key="Env:APP_SN" value="458"/>
	<context key="Env:APP_REF" value="SRSRSimpleMult"/>
</execute-transaction>'),'*/context/@key') FROM DUAL;
So I use XMLSequence (and not XMLTable because I'm still on Oracle 10g1) but the following select returns nothing
select COLUMN_VALUE FROM table(xmlsequence(extract(XMLTYPE('<execute-transaction app-ref="SRSRSimpleMult" app-sn="458" login="CARNI">
	<context key="Env:LOGIN" value="CARNI"/>
	<context key="Env:APP_SN" value="458"/>
	<context key="Env:APP_REF" value="SRSRSimpleMult"/>
</execute-transaction>'),'*/context/@key')));
However if I simply remove the "@key" in the XPath expression, the select gives me back a good result ! (but with the context tag that I don't care)

Can someone tell me why the SELECT doesn't return a result when the xpath expression contains the "@key" attribute ?

Thx
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 27 2011
Added on Mar 30 2011
1 comment
895 views