Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
32
Добавлен:
16.04.2013
Размер:
4.96 Mб
Скачать

Grouping Operations into Transactions

The WORK option of the ROLLBACK command has no function.

To roll back to a savepoint defined in the current transaction, use the TO option of the ROLLBACK command. For example, either of the following statements rolls back the current transaction to the savepoint named POINT1:

SAVEPOINT Point1;

...

ROLLBACK TO SAVEPOINT Point1; ROLLBACK TO Point1;

Defining Transaction Savepoints

To define a savepoint in a transaction, use the SAVEPOINT command. The following statement creates the savepoint named ADD_EMP1 in the current transaction:

SAVEPOINT Add_emp1;

If you create a second savepoint with the same identifier as an earlier savepoint, the earlier savepoint is erased. After creating a savepoint, you can roll back to the savepoint.

There is no limit on the number of active savepoints for each session. An active savepoint is one that has been specified since the last commit or rollback.

An Example of COMMIT, SAVEPOINT, and ROLLBACK

Table 5–3 shows a series of SQL statements that illustrates the use of COMMIT, SAVEPOINT, and ROLLBACK statements within a transaction.

Table 5–1 Use of COMMIT, SAVEPOINT, and ROLLBACK

SQL Statement

Results

 

 

SAVEPOINT a;

First savepoint of this transaction

DELETE...;

First DML statement of this transaction

SAVEPOINT b;

Second savepoint of this transaction

INSERT INTO...;

Second DML statement of this transaction

SAVEPOINT c;

Third savepoint of this transaction

UPDATE...;

Third DML statement of this transaction.

ROLLBACK TO c;

UPDATE statement is rolled back, savepoint C remains defined

5-6 Oracle Database Application Developer's Guide - Fundamentals

Тут вы можете оставить комментарий к выбранному абзацу или сообщить об ошибке.

Оставленные комментарии видны всем.

Соседние файлы в папке Oracle 10g