<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.lockAcquire.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.lockAcquire</api:function-name><api:suggest>xdmp.lockacquire</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>lockacquire</api:suggest><api:function-link mode="xquery" fullname="xdmp:lock-acquire">/apidoc/8.0/xdmp:lock-acquire.xml</api:function-link><api:function mode="javascript" name="lockAcquire" type="builtin" lib="xdmp" category="UpdateBuiltins" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.lockAcquire"><api:summary>
  Acquire a lock on a document or directory for an extended amount of time.
  Locks restrict updates to a document or directory to the user who acquires
  the lock.
</api:summary><api:params><api:param name="uri" type="xs:string"><api:param-description>
    The URI of the document or directory to be locked.
  </api:param-description><api:param-name>uri</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="scope" type="xs:string?" optional="true"><api:param-description>
    The lock scope ("exclusive" or "shared").  The default is "exclusive".
  </api:param-description><api:param-name>scope</api:param-name><api:param-type>String?</api:param-type></api:param><api:param name="depth" type="xs:string?" optional="true"><api:param-description>
    The lock depth ("0" or "infinity").  "0" locks the URI only, and "infinity"
    locks the URI (the document or directory) and all of its children.  The
    default is "0".
  </api:param-description><api:param-name>depth</api:param-name><api:param-type>String?</api:param-type></api:param><api:param name="owner" type="item()*" optional="true"><api:param-description>
    Alternate description of the lock owner.  If not specified  or if
    specified as the empty sequence ( () ), then the owner is the user name
    of the user requesting the lock.
  </api:param-description><api:param-name>owner</api:param-name><api:param-type>ValueIterator</api:param-type></api:param><api:param name="timeout" type="xs:unsignedLong?" optional="true"><api:param-description>
    Requested lock timeout in seconds. If not specified or if specified as the
    empty sequence ( () ) or if specified as 0, then the timeout is infinite.
  </api:param-description><api:param-name>timeout</api:param-name><api:param-type>String?</api:param-type></api:param></api:params><api:return>null</api:return><api:usage>
   <p xmlns="http://www.w3.org/1999/xhtml">If you lock a directory specifying a depth of "infinity", the directory
   and all of it children (all documents and directories with a URI started with
   the locked directory) are locked. You will not be able to add any children
   to the directory until the lock is released.</p>
   <p xmlns="http://www.w3.org/1999/xhtml">When a user locks a URI, it is locked to other users, but not to the user
   who locked it.  For example, if the user <em>sam</em> locks the URI
   <code>/home/sam.xml</code> by issuing the statement
   <code>xdmp:lock-acquire("/home/sam.xml")</code>, the user <em>sam</em>
   can still issue update commands to the document at that URI, but other users
   (for example, the user <em>josh</em>) will get an exception if they try
   to update the document.</p>
   <p xmlns="http://www.w3.org/1999/xhtml">If you attempt to acquire a lock on a document that already has a lock,
   the XDMP-LOCKCONFLICT exception is thrown.</p>
   <p xmlns="http://www.w3.org/1999/xhtml">If you attempt to update a document that is locked by another user,
   the XDMP-LOCKED exception is thrown.</p>
   <p xmlns="http://www.w3.org/1999/xhtml">Note that the lock described here is a relatively heavy persistent
   document lock for file system emulation through WebDAV, not a relatively
   light transaction lock for database consistency.</p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
declareUpdate();
xdmp.lockAcquire("/example.json",
   "exclusive", "0", "george", "120")
=&gt; ()
</pre></api:example></api:function></api:function-page>