SQL ROLLBACK WORK Statement

PURPOSE:  This statement signals the unsuccessful end-of-transaction.  A transaction is a group of SQL statements whose changes are logically connected and can be made permanent or undone as a unit.  All updates made during this transaction are undone, all row locks are released, and active SQL SELECT statements are closed.

When you update the Oracle Server in some way, that update should initially be regarded as tentative only - tentative in the sense that, if something subsequently goes wrong, the update may be undone.  Updates remain tentative until an SQL COMMIT or SQL ROLLBACK statement is executed.  The SQL ROLLBACK statement undoes or rolls back all tentative changes.

A transaction begins with the first executable SQL statement after a COMMIT, ROLLBACK, or connection to the database.

Syntax

SQL ROLLBACK WORK

Example

SQL SELECT * FROM BOOKS_ORA WHERE "BOOKS_ORA.TYPE_CODE = 'for_lang'"
START:10
  SQL FETCH NEXT ROW
LEAVE:10 IF @SQLCODE # 0
  SQL UPDATE BOOKS_ORA SET "BOOKS_ORA.PUB_CODE = '0736'" CURRENT ROW
REPEAT:10

FILL MENU_ASK_EM_IF_OK_ID:D
IF:10 @MENU_KEYWORD = 'YES'
  SQL COMMIT WORK
ORIF:10 @MENU_KEYWORD = 'NO'
  SQL ROLLBACK WORK
CONTINUE:10

NOTES:  You cannot roll back a transaction after an SQL COMMIT WORK statement has been executed.

SEE ALSO:  SQL COMMIT WORK statement

SQL Insert Statement    SQL Select Statement