Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Looping and querying data from XML clob
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

2 Posts

Posted - 10/05/2013 :  13:11:01  Show Profile  Reply with Quote

Using a code snippet borrowed from a co-worker, I have put together a query that, among other things, pulls a list value out of an xml clob field and displays it in the query results. My query as it stands right now is below, followed by a snippet from the xml clob that I am pulling from.
select * from 
  (Select Wtr_Service_Tag, Wtr_Tran_Origin, Wtr_Send_Date, Wtr_Receive_Date, 
    to_char(substr(wtr_req_xml,instr(substr(wtr_req_xml,1,8000),'SID')+8,12)) Asset_Tag
  from ws_transactions
  Where Wtr_Service_Tag In ('20458749610')
    And Wtr_Req_Xml Like ('%CSM%')
  Order By Wtr_Receive_Date Desc)
where rownum = 1;

<LIST NAME="AssetTag">
 <VALUE SID="1">186037</VALUE>
 <VALUE SID="2">186038</VALUE>

This query is only able to pull the first value in the list.

I have two questions that I am hoping I can get some help with.
    [1]How can I edit this query to pull all of the list items when there are more than 1? I have another field, in a separate table, that I can pull from to get that number.

    [2]This one may be more complex. As currently written, the query pulls a fixed number of characters from the xml clob and either returns not enough data, or too much because the values I need to pull could be of varying lengths. I have no way to query what those lengths might be.

Thank you in advance for your help. I hope I have provided enough information. I have I have not, I will gladly respond back with anything else that is needed.


James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 10/06/2013 :  08:31:07  Show Profile  Reply with Quote
Are you using Microsoft SQL Server? If you are not, you might want to post the question in a forum specific to your DBMS provider. This forum is for Microsoft SQL Server. I was going to write a query for you, but then I realized that the "CROSS APPLY" operator that I would be using is not available in some of the other DBMS systems.
Go to Top of Page

Starting Member

2 Posts

Posted - 10/06/2013 :  13:13:37  Show Profile  Reply with Quote
Thanks James.

I somehow missed that this forum was that specific. We use and oracle database and SQL developer to do our querying.

Sorry the for the intrusion.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000