A ROLLBACK statement rolls back a transaction, undoing work performed but not committed, decrementing the $TLEVEL transaction level counter, and releasing locks. ROLLBACK is used to restore the database to a previous consistent state.

A ROLLBACK rolls back all work completed during the current transaction, resets the $TLEVEL transaction level counter to zero and releases all locks. This restores the database to its state before the beginning of the transaction. ROLLBACK and ROLLBACK WORK are equivalent statements; both versions are supported for compatibility.

A ROLLBACK TO SAVEPOINTpointname rolls back all work done since the specified savepoint and decrements the $TLEVEL transaction level counter by the number of savepoints undone. When all savepoints have been either rolled back or committed and the transaction level counter reset to zero, the transaction is completed. If the specified savepoint does not exist, or has already been rolled back, ROLLBACK issues an SQLCODE -375 error and rolls back the entire current transaction.

A roll back does not decrement the IDKey counter for a default class. The IDKey is automatically generated by $INCREMENT (or $SEQUENCE), which maintains a count independent of the SQL transaction.

A roll back does not reverse the creation, modification, or purging of a Cached Query. These operations are not treated as part of a transaction.

A DDL operation or a Tune Table operation that occur within a transaction may create and run a temporary routine. This temporary routine is treated the same as a Cached Query. That is, the creation, compilation, and deletion of a temporary routine are not treated as part of the transaction. The execution of the temporary routine is considered part of the transaction.

For non-SQL items rolled back or not rolled back, refer to the ObjectScript TROLLBACK command.

The TransactionsSuspended() method of the %SYSTEM.Process class can be used to suspend and resume all current transactions system-wide. Suspending transactions suspends journaling of changes. Therefore, if transaction suspension occurred during the current transaction, ROLLBACK cannot roll back any changes made while transactions were suspended; however, ROLLBACK rolls back any changes made during the current transaction that occurred before or after the transaction suspension was in effect.

ObjectScript and SQL transaction commands are fully compatible and interchangeable, with the following exception:

ObjectScript TSTART and SQL START TRANSACTION both start a transaction if no transaction is current. However, START TRANSACTION does not support nested transactions. Therefore, if you need (or may need) nested transactions, it is preferable to start the transaction with TSTART. If you need compatibility with the SQL standard, use START TRANSACTION.