IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  XQuery - Deleting using joins

    Posted Wed May 12, 2004 12:29 AM

    Hello!

    I have problem with a - in my opinion - complex XQuery.

    I have three doctypes and want to do a nested delete.

    doctype b depends on doctype a
    doctype c depends on doctype b

    So for example:
    If a delete a element in doctype a where aID = 5, i want to delete all doctypes b where aID = bID. So far, seems no problem. But now I also want to delete all doctypes c where $cOtherID = $bOtherID AND the above options matches.

    Get all elements with:

    for $a in input()/docA
    for $b in input()/docB
    where $a/ID = $b/ID
    and $b/ID = 5
    return

    {$a/ID}
    {$b/otherID}
    {for $c in input()/docC
    where $c/otherID = $b/otherID
    return $c/anotherValue }


    It works fine. Gives me a list like that:


    5
    1
    1
    3
    4


    Now, i want to rewrite this query to delete all doctypes a,b and c where the query returns values.

    Any ideas? Or should I split this into different queries? One query would be great.

    Thanks in advance.

    Regards,
    Christian


    #Tamino
    #webMethods
    #API-Management


  • 2.  RE: XQuery - Deleting using joins

    Posted Wed May 12, 2004 10:40 AM

    Hi,

    You can use an FLWU expression to perform the delete operation. The following statement should do the job:

    update
    for $a in input()/docA
    for $b in input()/docB
    let $d := for $c in input()/docC
    where $c/otherID = $b/otherID
    return $c
    where $a/ID = $b/ID
    and $b/ID = 5
    do
    (
    delete $a
    delete $b
    delete $d
    )

    Regards,
    Thorsten


    #API-Management
    #Tamino
    #webMethods


  • 3.  RE: XQuery - Deleting using joins

    Posted Wed May 12, 2004 01:05 PM

    Hi Thorsten!

    Thanks again for your help!

    Just one thing missing in your query.
    Has to be

     
    do
    ( 
    delete $a/..
    delete $b/..
    delete $d/..
    )



    to delete all root element.

    Regards,
    Christian


    #webMethods
    #API-Management
    #Tamino