<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/Global-Object.declareUpdate.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>Global-Object.declareUpdate</api:function-name><api:suggest>global-object.declareupdate</api:suggest><api:suggest>global</api:suggest><api:suggest>object</api:suggest><api:suggest>declareupdate</api:suggest><api:function mode="javascript" name="declareUpdate" type="builtin" lib="Global-Object" category="JavaScript Global Object" class="javascript" hidden="false" bucket="MarkLogic Built-In Functions" prefix="Global-Object" namespace="" fullname="Global-Object.declareUpdate"><api:summary>
  Declares the statement to be an update.

  <p xmlns="http://www.w3.org/1999/xhtml">A JavaScript statement is executed as a query unless declareUpdate() is
  called at the beginning of the statement.  Calling declareUpdate with an
  options argument where <code>explicitCommit</code> property is set to true 
  starts a multi-statement transaction and requires an explicit commit or 
  rollback to complete the transaction.  If the options argument is omitted, 
  or the property <code>explicitCommit</code> property is set to false, an 
  update is automatically committed.  XDMP-OWNTXN is thrown if the request 
  is in an open transaction. </p>
</api:summary><api:params><api:param name="options" type="Object" optional="true"><api:param-description>
    Options to use for this operation.  If "explicitCommit" property is set to
    true, declareUpdate starts a multi-statement transaction and requires an
    explicit commit or rollback to complete the transaction.
  </api:param-description><api:param-name>options</api:param-name><api:param-type>Object</api:param-type></api:param></api:params><api:return>Null</api:return><api:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  declareUpdate();
  var person = {name:"Jon", age:50};
  xdmp.documentInsert("p.json", person);
</pre></api:example><api:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  declareUpdate({explicitCommit: true});
  var person = {name:"Jon", age:50};
  xdmp.documentInsert("p.json", person);
  // because explicitCommit is true, you must call xdmp.commit (or
  // call it in another statement that uses the transaction started 
  // in this statement)
  xdmp.commit();
</pre></api:example></api:function></api:function-page>