Hi Paul, you've run into the basic building block of XQuery --by default, lazy evaluation will defer the save operation if it can. (I don't think it's a transaction issue as others have suggested, although that also comes into play)

A couple of things you can try to force evaluation:

1. refer to $save in another let, after the first one. This will force the interpreter to evaluate $save. Something like let $save := saveFunction() return if ($save) then ... else ... 2. wrap saveFunction() in xdmp:eager(). This is a (not normally recommended) way to force evaluation of an expression. 3. Probably the preferred way to address this though would be to put it into two expressions

(
let $a := ...
let $b := ...
return saveFunction($x),
if (wasSaved())
then anotherFunction()
else ()
)

Charles


On 04/16/2013 11:57 AM, Chad Bishop wrote:
Greetings,

I have the following situation:

let $var ...
for ...
where ...
return
                 let $a ...
                 let $b ...
                 let $save := saveFunction($param)
                 return ($a, anotherFunction($b)...)

That saveFunction is inserting a document...or supposed to.

What I've found is it doesn't actually insert the document unless I:

return $save

Why is that?  It matters in this situation because anotherFunction() depends on 
the document existing.

Thank you for any help,

-Chad



_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

--
Charles Greer
Senior Engineer
MarkLogic Corporation
[email protected]
Phone: +1 707 408 3277
www.marklogic.com

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to