Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5

    Unanswered: 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

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •