Skip to Main Content

SQL & PL/SQL

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!

Using XMLTABLE

2747506Sep 17 2014 — edited Sep 18 2014


Hi,

I have an Oracle table called WMLogger. It has one CLOB column called 'BODY' that contains XML data. It also has a KEYID column that mistakenly has the wrong value in some cases. I am trying to create an UPDATE statement (or even a good select statement) to replace the KEYID with an XML attribute found in the BODY's XML.

Here's an example of the XML:

<INTERFACE MESSAGE_TYPE="RL" EVENT_DTTM = "13-Sep-2012 13:40:43.01" BUSINESS_UNIT="10258" SequenceNumber="0" xmlns="http://Corning.COF.MESSC.PLANT_TO_PS.Schema/Plant.Superschema">

<CONTAINER CONTAINER_ID_CI="800000000001" COUNT="1" CONTAINER_TYPE="" BOX_TYPE="">

<DETAIL>

<CNTR_DETAIL ID="800000000001" SLOT_ID="" ZONE="R01R02" SIZE="2" />

</DETAIL>

</CONTAINER>

</INTERFACE>

This SELECT statement seems to return no rows:

select l.KEYID,t.*
FROM WMLOGGER l,
XMLTABLE ('/CONTAINER[1]'
          PASSING XMLTYPE(l.BODY)
          COLUMNS CONTAINER_ID_CI VARCHAR2(20) PATH '@CONTAINER_ID_CI') t
WHERE l.TAG = 'RL';

I have also tried '/INTERFACE/CONTAINER[1}' and still get no rows returned. Any suggestions?

Thanks,

David

BANNER                                                        

----------------------------------------------------------------

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

PL/SQL Release 10.2.0.4.0 - Production                          

CORE 10.2.0.4.0 Production                                        

TNS for Linux: Version 10.2.0.4.0 - Production                  

NLSRTL Version 10.2.0.4.0 - Production     

This post has been answered by Solomon Yakobson on Sep 17 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 16 2014
Added on Sep 17 2014
2 comments
261 views