webMethods

webMethods

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.  how to use position() in an update query?

    Posted Fri June 02, 2006 11:08 PM

    I need to update around 600,000 documents. In the past I have only been successful updating 1000 or 2000 docs at a time.

    Is it possible to use position() in a update query?

    I tried, without any luck…

    ( update
    for …
    where …
    do replace …
    ) [position() < 1001]

    update
    (
    for …
    where …
    ) [position() < 1001]

    do replace …


    #Tamino
    #API-Management
    #webMethods


  • 2.  RE: how to use position() in an update query?

    Posted Mon June 05, 2006 11:21 AM

    Hi!
    I don’t know if it’s possible, but I have used:

    declare namespace tf=“http://namespaces.softwareag.com/tamino/TaminoFunction
    update
    for $p …
    where tf:getInoId($p) < … and tf:getInoId($p) > …
    do replace …

    I hope can it are useful to you.
    Best regards,

    Pam


    #Tamino
    #webMethods
    #API-Management


  • 3.  RE: how to use position() in an update query?

    Posted Tue June 06, 2006 06:21 PM

    Hi,

    The position() filter can only be applied to XQuery expressions. Rewriting the update expression in the following way should do the job:

    update
    for $x in (for $y in … where … return …)[position() < 100]
    do …

    Best Regards,

    Thorsten


    #webMethods
    #API-Management
    #Tamino


  • 4.  RE: how to use position() in an update query?

    Posted Wed June 07, 2006 10:10 PM

    ok… not sure I got this right

    update

    for $outer in (

    for $inner in input()/doc

     where $inner/system='X'
    and   $inner/disclosure_level = 'Public' 
    

    return

    )[position() < 100]

    let $target := $outer/disclosure_level

    do
    replace $target with
    <disclosure_level>Test</disclosure_level>

    … this runs without any error, but does not update any docs.

    The where condidtion is good… if I run this, I get many nodes in return …

    for $inner in input()/doc

     where $inner/system='X'
    and   $inner/disclosure_level = 'Public' 
    

    return
    $inner/disclosure_level

    I assume I’ve got the syntax wrong.

    -Kim


    #Tamino
    #webMethods
    #API-Management


  • 5.  RE: how to use position() in an update query?

    Posted Thu June 08, 2006 11:21 AM

    Hi,

    Your inner query returns new constructed elements, which can’t be updated. To perfrom a successfull update the inner query should return elements retrieved from the database. You can achieve this by rewriting the query in the following way:

    update
    for $outer in (
    for $inner in input()/doc
    where $inner/system=‘X’
    and $inner/disclosure_level = ‘Public’
    return $inner
    )[position() < 100]
    let $target := $outer/disclosure_level
    do
    replace $target …

    The inner query now returns the bindings of $inner instead of the element .

    Best Regards,

    Thorsten


    #webMethods
    #API-Management
    #Tamino


  • 6.  RE: how to use position() in an update query?

    Posted Thu June 08, 2006 06:02 PM

    Thorston,

    That worked.
    Thank you.

    -Kim


    #API-Management
    #Tamino
    #webMethods