![]() |
|
Use the ROLLBACK WORK statement to cancel a transaction deliberately and undo any changes that occurred since the beginning of the transaction. The ROLLBACK WORK statement restores the database to the state that it was in before the transaction began.
The ROLLBACK WORK statement is valid only in databases with transactions.
In a database that is not ANSI-compliant, start a transaction with a BEGIN WORK statement. You can end a transaction with a COMMIT WORK statement or cancel the transaction with a ROLLBACK WORK statement. The ROLLBACK WORK statement restores the database to the state that existed before the transaction began.
Use the ROLLBACK WORK statement only at the end of a multistatement operation.
The ROLLBACK WORK statement releases all row and table locks that the cancelled transaction holds. If you issue a ROLLBACK WORK statement when no transaction is pending, an error occurs.
In an ANSI-compliant database, transactions are implicit. Transactions start after each COMMIT WORK or ROLLBACK WORK statement, so no BEGIN WORK statement is required. If you issue a ROLLBACK WORK statement when no transaction is pending, the statement is accepted but has no effect.
In ESQL/C, the ROLLBACK WORK statement closes all open cursors except those that are declared with hold. Hold cursors remain open after a transaction is committed or rolled back.
If you use the ROLLBACK WORK statement within an SPL routine that a WHENEVER statement calls, specify WHENEVER SQLERROR CONTINUE and WHENEVER SQLWARNING CONTINUE before the ROLLBACK WORK statement. This step prevents the program from looping if the ROLLBACK WORK statement encounters an error or a warning.
The WORK keyword is optional in a ROLLBACK WORK statement. The following two statements are equivalent:
Related statements: BEGIN WORK and COMMIT WORK
For a discussion of transactions and ROLLBACK WORK, see the Informix Guide to SQL: Tutorial.