<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.setTransactionMode.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.setTransactionMode</api:function-name><api:suggest>xdmp.settransactionmode</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>settransactionmode</api:suggest><api:function-link mode="xquery" fullname="xdmp:set-transaction-mode">/apidoc/8.0/xdmp:set-transaction-mode.xml</api:function-link><api:function mode="javascript" name="setTransactionMode" type="builtin" lib="xdmp" category="TransactionBuiltins" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.setTransactionMode"><api:summary>
  Set the transaction mode for the current session. Calling this function
  has no effect on existing transactions.
</api:summary><api:params><api:param name="value" type="xs:string"><api:param-description>
    The new transaction mode. Must be one of "auto", "query", "update",
    or "update-auto-commit".
  </api:param-description><api:param-name>value</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">
     The mode a transaction runs under is fixed when the transaction is
     created. Calling <code>xdmp:set-transaction-mode</code> during a
     query does not affect the current transaction.
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">
     The transaction mode defaults to "auto". To change the mode, you
     may either call <code>xdmp:set-transaction-mode</code> or use the
     <code>xdmp:transaction-mode</code> option.
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">
     Use the <code>xdmp:transaction-mode</code> option to set the
     transaction mode before a transaction exists. Use
     <code>xdmp:set-transaction-mode</code> to set the mode during execution.
  </p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
//  this transaction runs in update mode, due to the declaration
xdmp.eval('declareUpdate({explicitCommit: true}); \n\
xdmp.setTransactionMode("query"); \n\
xdmp.documentInsert("/docs/mydoc.json", {"myData": "data"}); \n\
xdmp.commit();');

// but this new transaction runs in query mode 
xdmp.eval('var res = []; \n\
res.push(xdmp.getTransactionMode()); \n\
res.push(cts.doc("/docs/mydoc.json")); \n\
res;');

=&gt; ["query",{"myData":"data"}]
</pre></api:example></api:function></api:function-page>