Tim,

I don't know that the function values is the root cause. A separate transaction 
should work to write updates without making the entire query into an update, 
however you have to send the URI and/or XPath of the nodes you want to update, 
then re-retrieve the nodes in that transaction. XDMP-UPEXTNODES indicates 
you're sending a node into the eval and then trying to update it. 

This example throws the XDMP-UPEXTNODES exception you are seeing:

xdmp:document-insert("/test/test.xml", <test/>)
;

let $count := count(cts:search(doc(), ())[1 to 10])  (: some large read 
operation :)
let $audit := xdmp:eval('
  declare variable $t external;
  xdmp:node-insert-child($t, <audit/>)
', (xs:QName("t"), doc("/test/test.xml")/test))
return "done"

but this works:

xdmp:document-insert("/test/test.xml", <test/>)
;

let $count := count(cts:search(doc(), ())[1 to 10])  (: some large read 
operation :)
let $audit := xdmp:eval('
  declare variable $u external;
  xdmp:node-insert-child(doc($u)/test, <audit/>)
', (xs:QName("u"), "/test/test.xml"))
return "done"
;
doc("/test/test.xml")

Also look at xdmp:path() and xdmp:unpath() if you need a node rather than just 
a URI of a doc.

Yours,
Damon

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Tim Finney
Sent: Tuesday, September 20, 2011 5:47 PM
To: [email protected]
Subject: [MarkLogic Dev General] Writing logs with the app-user role

Dear List,

I would like to use the xdmp:apply(xdmp:function(), ...) pattern in an
application. The functionality is mainly read-only, where an
unprivileged role (app-user) is allowed to search and display documents
in a database. However, I would also like to record user search strings
and to store feedback and errors in database documents. I would prefer
to always run the application as a query statement to avoid the
performance hit of running as an update transaction.

Is there a way to run as a query statement and also allow the app-user
role to write to the database when using the
xdmp:apply(xdmp:function(), ...) pattern? How much of a performance hit
is incurred by running as an update? I have tried using an amped
function to log feedback as a distinct transaction but get a
"XDMP-UPEXTNODES Cannot update external nodes" error.

Best,

Tim Finney


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

Reply via email to