how to use position() in an update query?

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 …

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

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

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

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

Thorston,

That worked.
Thank you.

-Kim