Loading TOC...

MarkLogic Server 11.0 Product Documentation
xdmp.rollback

xdmp.rollback() as null

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.transactionRollback for the current host and transaction: xdmp.transactionRollback(xdmp.host(), xdmp.transaction()).

See Also

Example

// multi-statement transaction 
declareUpdate({explicitCommit: true});

xdmp.documentInsert("/docs/first.json", {"first": 1});
xdmp.documentInsert("/docs/second.json", {"second": 2});
xdmp.rollback();

  => Empty. The transaction is rolled back. The documents are
     not added to the database. The transaction ends.

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.