If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How do I compare XML variable to XML column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-13-10, 17:00
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
How do I compare XML variable to XML column

I am writing a Stored procedure in which I need to see if a parameter that is passed in of type XML is located in a column of a table that is also XML data type. The ordering of the data in either XML should not matter, all that needs to match is that all of the items in the table match all of the items in the parameter. What I am looking for is if you turned the XML in the parameter to a result set of a query, that its contents would exactly match the same result set conversion of the column.

Any Ideas?

DB2 V9.5.5 Linux 64 Bit

Andy
Reply With Quote
  #2 (permalink)  
Old 05-15-10, 21:38
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
What do you mean with "the ordering of data [...] should not matter"? XML is a data structure that has an inherent ordering of its elements. That means, if you have two documents like:
Code:
<a>
   <b>1</b>
   <b>2</b>
</a>
and
Code:
<a>
   <b>2</b>
   <b>1</b>
</a>
you have two completely different documents, which are not identical. Thus, I think that you may not use the correct data structure (XML) for your requirements.

What you can do is to split the 2 documents into a temp table, then do a set-oriented comparison.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On