Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The sample code won't run as written because of syntax errors: there are missing variables and there is a function after the expression body. But looking past that, there is nothing here to suggest a multi-statement transaction. Instead this looks like a single statement, and so the multiple updates to <code>$uri</code> conflict with each other. The call to <code>dls:document-update</code> updates <code>$uri</code> and then <code>dls:document-checkin</code> tries to update the same document in the same transaction, causing a conflict. The same logic applies to <code>$sub-uri</code>. In the docs, <a href="http://docs.marklogic.com/dls:document-update" rel="nofollow">http://docs.marklogic.com/dls:document-update</a> notes that "This function must be called in a separate transaction from the dls:document-checkout and dls:document-checkin".</p> <p>MarkLogic transactions behave differently than you might expect, because XQuery is not an imperative or procedural language. Try reading up on transactions at <a href="http://docs.marklogic.com/guide/app-dev/transactions" rel="nofollow">http://docs.marklogic.com/guide/app-dev/transactions</a></p> <p>In most cases I prefer to write separate transactions as separate requests, but here is the first part of your query written using semicolons to separate transactions. You might try rewriting the same code in <code>xdmp:commit</code> style, to understand the difference.</p> <pre><code>(: multiple statements with semicolons :) (: statement 1 :) import module namespace dls="http://marklogic.com/xdmp/dls" at "/MarkLogic/dls.xqy"; declare variable $content := &lt;test&gt;content&lt;/test&gt;; declare variable $content-collection := "content"; declare variable $uri := "test"; dls:document-update( $uri, $content, "Main Document Updated", fn:true(), xdmp:default-permissions(), $content-collection) ; (: statement 2 :) import module namespace dls="http://marklogic.com/xdmp/dls" at "/MarkLogic/dls.xqy"; declare variable $uri := "test"; dls:document-checkin($uri, fn:true()) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload