background image
<< Rolling Back Transaction Changes | Creating Savepoints >>
<< Rolling Back Transaction Changes | Creating Savepoints >>

Using the SAVEPOINT Statement

Controlling Transactions
2-32 Oracle Database 2 Day Developer's Guide
Setting Savepoints
You can use the
SAVEPOINT
statement to identify a point in a transaction to which
you can later roll back. Because you can use as many savepoints as your application
requires, you can implement greater transaction control in your application.
In
Example 2­54
, you will use the
ROLLBACK
statement after adding a new row to the
regions
table.
Example 2­54 Using the SAVEPOINT Statement
UPDATE regions
SET region_name = 'Middle East'
WHERE region_name = 'Middle East and Africa';
SAVEPOINT reg_rename;
UPDATE countries
SET region_id = 5
WHERE country_id = 'ZM';
SAVEPOINT zambia;
UPDATE countries
SET region_id = 5
WHERE country_id = 'NG';
SAVEPOINT nigeria;
UPDATE countries
SET region_id = 5
WHERE country_id = 'ZW';
SAVEPOINT zimbabwe;
UPDATE countries
SET region_id = 5
WHERE country_id = 'EG';
SAVEPOINT egypt;
ROLLBACK TO SAVEPOINT nigeria;
COMMIT;
The results for each
UPDATE
and
SAVEPOINT
statement follow.
1 row updated.
See Also:
Oracle Database SQL Language Reference