Skip Headers

PL/SQL User's Guide and Reference
10g Release 1 (10.1)

Part Number B10807-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

ROLLBACK Statement

The ROLLBACK statement is the inverse of the COMMIT statement. It undoes some or all database changes made during the current transaction. For more information, see "Overview of Transaction Processing in PL/SQL".

Syntax

Description of rollback_statement.gif follows
Description of the illustration rollback_statement.gif

Keyword and Parameter Description


ROLLBACK

When a parameterless ROLLBACK statement is executed, all database changes made during the current transaction are undone.


ROLLBACK TO

Undoes all database changes (and releases all locks acquired) since the savepoint identified by savepoint_name was marked.


SAVEPOINT

Optional, for readability only.


savepoint_name

An undeclared identifier, which marks the current point in the processing of a transaction. For naming conventions, see "Identifiers".


WORK

Optional, for readability only.

Usage Notes

All savepoints marked after the savepoint to which you roll back are erased. The savepoint to which you roll back is not erased. For example, if you mark savepoints A, B, C, and D in that order, then roll back to savepoint B, only savepoints C and D are erased.

An implicit savepoint is marked before executing an INSERT, UPDATE, or DELETE statement. If the statement fails, a rollback to this implicit savepoint is done. Normally, just the failed SQL statement is rolled back, not the whole transaction. If the statement raises an unhandled exception, the host environment determines what is rolled back.

In SQL, the FORCE clause manually rolls back an in-doubt distributed transaction. PL/SQL does not support this clause. For example, the following statement is not allowed:

ROLLBACK WORK FORCE '24.37.85';  -- not allowed

In embedded SQL, the RELEASE option frees all Oracle resources (locks and cursors) held by a program and disconnects from the database. PL/SQL does not support this option. For example, the following statement is not allowed:

ROLLBACK WORK RELEASE;  -- not allowed

Related Topics

COMMIT Statement, SAVEPOINT Statement