MarkLogic 12 EA 1 Product Documentation
xdmp:rollback

xdmp:rollback() as empty-sequence()

Summary

Roll back the current transaction.

Usage Notes

When a transaction is rolled back, the current statement immediately terminates, updates made by any statement in the transaction are discarded, and the transaction terminates.

Transactions running in "update" or "query" transaction mode should be explicitly rolled back, using this function. Failure to explicitly commit or roll back such a transaction leaves the transaction open until transaction timeout, thus unnecessarily holding resources and locks, potentially blocking other transactions.

Transactions running in "auto" transaction mode may also use this function, to roll back a transaction without raising an error.

The result of a statement terminated with xdmp:rollback is always the empty sequence.

This function is equivalent to calling xdmp:transaction-rollback for the current host and transaction: xdmp:transaction-rollback(xdmp:host(), xdmp:transaction()) .

See Also

Example

  (: multi-statement transaction :)
  declare option xdmp:transaction-mode "update";

  xdmp:document-insert("/docs/first.xml", <first/>);
  xdmp:document-insert("/docs/second.xml", <second/>);
  xdmp:rollback();

  => Empty. The transaction is rolled back. The documents are
     not added to the database. The transaction ends.
Powered by MarkLogic Server | Terms of Use | Privacy Policy