Hi,

This is what's happening :

Your query works the first time you run it but fails subsequent times you run 
it.

This is because you need to use dls:document-insert-and-manage() on your first 
insertion and dls:document-checkout-update-checking() or a series of equivalent 
functions on subsequent uses.

This should probably do the trick:

let $contents :={'key':'value'}
return  xdmp:invoke-function(
      function() {
if(dls:document-is-managed("/test/test001.json")) then
  dls:document-checkout-update-checkin("/test/test001.json", 
$contents,(),fn:true())
else
(
dls:document-insert-and-manage("/test/test001.json", 
fn:true(),$contents,(),(),"TEST-COLLECTION"), xdmp:commit() )
},<options xmlns="xdmp:eval">
        <transaction-mode>update</transaction-mode>
      </options>);


Best,
Rob

Rob Szkutak
Senior Consultant
MarkLogic Corporation
rob.szku...@marklogic.com
www.marklogic.com<http://www.marklogic.com>

________________________________
From: general-boun...@developer.marklogic.com 
[general-boun...@developer.marklogic.com] on behalf of Shiv Shankar 
[shiv.shivshan...@gmail.com]
Sent: Wednesday, September 21, 2016 10:16 AM
To: general@developer.marklogic.com
Subject: [MarkLogic Dev General] Error :XDMP-CONFLICTINGUPDATES

Hi Rob,


I was just constructing the $contents . Any thoughts?

let $contents :={'key':'value'}
return  xdmp:invoke-function(
      function() {dls:document-insert-and-manage("/test/test001.json", 
fn:true(),$contents,(),(),"TEST-COLLECTION"), xdmp:commit() },<options 
xmlns="xdmp:eval">
        <transaction-mode>update</transaction-mode>
      </options>);

_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to