Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
2 replies Latest Post - ‏2014-04-17T03:26:33Z by Gary_Scarcella
Gary_Scarcella
Gary_Scarcella
22 Posts
ACCEPTED ANSWER

Pinned topic xmlexists for multiple search conditions

‏2014-04-16T15:41:48Z |

My customer has the following query which works

{code}

SELECT*                                                     

FROMBEM.EVNT

WHERE xmlexists('$c/AddressChange[NewAddress = "123 State Street"]'

passing EVNT_DATA_XML as "c") and

xmlexists('$c/AddressChange[OldAddress = "12345 State Street"]'

passing EVNT_DATA_XML as "c")

withur;

{code}

And they then changed it to use a single xmlexists.

Is this the best way to code this?

{code}

SELECT*                                                     

FROMBEM.EVNT

WHERE xmlexists('$c/AddressChange[NewAddress = "123 State Street"]

/ $c/AddressChange[OldAddress = "1234 State Street"]'

passing EVNT_DATA_XML as "c")

withur;

{code}

Separate each element using ' / '..  Seem correct? or is there a better syntax for this?

Thanks,

Gary.

  • MatthiasNicola
    MatthiasNicola
    321 Posts
    ACCEPTED ANSWER

    Re: xmlexists for multiple search conditions

    ‏2014-04-17T01:14:25Z  in response to Gary_Scarcella

    Hi Gary,

    assuming that the intention is to keep the semantics (result) of the original query unchanged, here is the recommended way to combine the two XMLEXISTS into one:

     

    SELECT*                                                     

    FROMBEM.EVNT

    WHERE xmlexists('$c/AddressChange[NewAddress = "123 State Street" and

                                     OldAddress = "12345 State Street" ]'

    passing EVNT_DATA_XML as "c")

     

    Does this help?

    Matthias