簡體   English   中英

MarkLogic 8 - 使用文檔管理和結帳的XQuery

[英]MarkLogic 8 - XQuery using Document manage and checkout

我嘗試了下面提到的xquery。 如果文檔未被管理,我想使用DLS查詢管理文檔,否則我想簽出文檔。

xquery version "1.0-ml";
import module namespace dls = "http://marklogic.com/xdmp/dls"  at "/MarkLogic/dls.xqy";

let $uri :="/root/189966_01.xml"

let $i := dls:document-is-managed($uri)

return 
  if ($i = fn:false())
  then 

    dls:document-manage($uri,  fn:false(),   "Baz is now a managed document") 

    (:  dls:document-checkout($uri, fn:true(), "updating doc", 3600) :)

  else if ($i = fn:true())
  then

      dls:document-checkout($uri, fn:true(), "updating doc", 3600) 

  else 

    "No action"

如果我身邊有任何問題,請糾正我。

xquery看起來很好。 只是對上述查詢進行重組 -

xquery version "1.0-ml";
import module namespace dls = "http://marklogic.com/xdmp/dls"  at "/MarkLogic/dls.xqy";    
let $uri :="/root/189966_01.xml"    
let $i := dls:document-is-managed($uri)    
return 
    if ($i = fn:false()) then     
        dls:document-manage($uri,  fn:false(),   "Baz is now a managed document")    
    else     
        if ($i = fn:true()) then    
            dls:document-checkout($uri, fn:true(), "updating doc", 3600)     
    else    
        ()

您無法在同一交易中結帳和管理。 您可以在同一請求中簽出2個獨立事務,由父事務管理(只要您在之前或期間沒有持有任何鎖定。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM