How to retrieve XML tag using sql [message #408897] |
Thu, 18 June 2009 04:20 |
huda10
Messages: 23 Registered: December 2008
|
Junior Member |
|
|
Hi,
I've the following xml file in database table column.
<DOCUMENT>
<AUTOSTREAM_DOC_ID>AK_178595</AUTOSTREAM_DOC_ID>
<LEAD_XML>
<SIEBELMESSAGE MESSAGEID="1-1T96JP" INTOBJECTNAME="MM SV CS SERVICE PROVIDER LEAD INBOUND" MESSAGETYPE="INTEGRATION OBJECT" INTOBJECTFORMAT="SIEBEL HIERARCHICAL">
<LISTOFMMSV>
<MMSVCSS>
<ID>1-6XI5Z1</ID>
</MMSVCSS>
</LISTOFMMSV>
</SIEBELMESSAGE>
</LEAD_XML>
</DOCUMENT>
I need to retrive xml tag "<SIEBELMESSAGE MESSAGEID="1-1T96JP" INTOBJECTNAME="MM SV CS SERVICE PROVIDER LEAD INBOUND" MESSAGETYPE="INTEGRATION OBJECT" INTOBJECTFORMAT="SIEBEL HIERARCHICAL">" using sql query ..
Can anybody please help ..
Thanks & Regards,
Abdul
|
|
|
|
Re: How to retrieve XML tag using sql [message #408904 is a reply to message #408899] |
Thu, 18 June 2009 04:42 |
huda10
Messages: 23 Registered: December 2008
|
Junior Member |
|
|
As mentioned in example 4.6 he following values inserted into table --
INSERT INTO warehouses VALUES
( 100, XMLType(
'<Warehouse whNo="100">
<Building>Owned</Building>
</Warehouse>'), 'Tower Records', 1003);
How do we retrieve tag "<Warehouse whNo="100">" (Not the value ).
|
|
|
|
|
|
Re: How to retrieve XML tag using sql [message #408915 is a reply to message #408911] |
Thu, 18 June 2009 05:17 |
ThomasG
Messages: 3212 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
Well, you can also extract the entire SIEBELMESSAGE tag. Of course the entire SIEBELMESSAGE tag is everything from <SIEBELMESSAGE ..> to </SIEBELMESSAGE>
CREATE TABLE testxml (
col xmltype
);
INSERT INTO testxml VALUES
( XMLType( '<DOCUMENT>
<AUTOSTREAM_DOC_ID>AK_178595</AUTOSTREAM_DOC_ID>
<LEAD_XML>
<SIEBELMESSAGE MESSAGEID="1-1T96JP" INTOBJECTNAME="MM SV CS SERVICE PROVIDER LEAD INBOUND"
MESSAGETYPE="INTEGRATION OBJECT" INTOBJECTFORMAT="SIEBEL HIERARCHICAL">
<LISTOFMMSV>
<MMSVCSS>
<ID>1-6XI5Z1</ID>
</MMSVCSS>
</LISTOFMMSV>
</SIEBELMESSAGE>
</LEAD_XML>
</DOCUMENT>'));
SELECT t.col.getClobVal() FROM testxml t;
SELECT t.col.extract('//SIEBELMESSAGE').getClobVal()
FROM testxml t;
Just
<SIEBELMESSAGE MESSAGEID="1-1T96JP" INTOBJECTNAME="MM SV CS SERVICE PROVIDER LEAD INBOUND" MESSAGETYPE="INTEGRATION OBJECT" INTOBJECTFORMAT="SIEBEL HIERARCHICAL">
wouldn't be valid XML anymore anyway, since the closing tag is missing.
There are dozens of different examples on the linked page.
[Updated on: Thu, 18 June 2009 05:19] Report message to a moderator
|
|
|