Cause
A transaction being run as a query attempted to perform an update. For example, using xdmp:apply to execute an update function when the xdmp:apply is in a query transaction.
This error also occurs if you use xdmp:eval or xdmp:invoke with same-statement isolation in a query transaction. You may only use same-statement isolation with update transactions.
For more information, see the discussion of Isolation option to xdmp:eval/invoke in the Application Developer's Guide.
Response
Possible solutions to this error include:
Use
different-transaction
isolation in the problem
xdmp:eval or
xdmp:invoke.
Use
xdmp:eval instead of
xdmp:apply if you know the applied function may be an update.
If the problem occurs with
xdmp:apply, and you know the applied function will perform an update, force the transaction to be an update. For example:
let $force-update :=
if (fn:true())
then ()
else xdmp:document-insert('/fake.xml', <fake></fake>)
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.