|
|
The ROLLBACK WORK statement undoes changes you have made to the
DBEnvironment during the current transaction, releases locks held by the
transaction, and closes cursors opened during the transaction. Other
transactions active in this session are not affected.
ISQL or Application Programs
ROLLBACK WORK [TO {SavePointNumber
:HostVariable
:LocalVariable
:ProcedureParameter}
RELEASE ]
- TO
The TO clause is used to roll back to a savepoint without ending the
current transaction.
If the TO clause is omitted, ROLLBACK WORK ends the current
transaction and undoes any changes that have been made in the
transaction.
- SavePointNumber
is the number assigned by ISQL to a savepoint when you issue the
SAVEPOINT statement interactively.
- HostVariable
is defined as an integer variable to which you assign a value when you
issue the SAVEPOINT statement programmatically, or in a
procedure.
- LocalVariable
contains a value in a procedure.
- ProcedureParameter
contains a value that is passed into or out of a procedure.
- RELEASE
terminates your DBE session.
When you omit the TO clause, all changes you have made to the
DBEnvironment since the most recent BEGIN WORK statement are
undone. In an application program, all open cursors are automatically
closed except those opened with the KEEP CURSOR option. Any
savepoints defined in the transaction are lost and become invalid.
The transaction is ended. Any cursor opened with the KEEP CURSOR
option is repositioned to its scan position as of the most recent
BEGIN WORK statement, and a new transaction is implicitly
started with the same isolation level.
The TO clause may not be used if any cursors that were opened with
the KEEP CURSOR option are still open. Issuing a ROLLBACK WORK
to a savepoint in this context results in an error message, and no
rollback is done.
When you specify the TO clause, all changes you have made to the
DBEnvironment since the designated savepoint are undone. If any
cursors opened with the KEEP CURSOR option were active in this
transaction, the statement fails and the rollback is not done. In an
application program or procedure, all open cursors are automatically
closed.
Any savepoints defined more recently than the designated savepoint
are lost and become invalid. The designated savepoint is still valid
and can be specified in a future ROLLBACK WORK statement. The
transaction is not ended. Any locks obtained since the savepoint was
set are released.
If the current transaction is the one in which you opened a cursor
with the KEEP CURSOR option, then the ROLLBACK WORK statement
closes the cursor and undoes any changes made through it.
Under some circumstances ALLBASE/SQL automatically rolls back a
transaction. For example, when service is restored after a system
failure, all uncommitted transactions are automatically backed
out.
If RELEASE is used, all cursors are closed and the current
connection is terminated.
The RELEASE option is not allowed within a procedure.
You do not need authorization to use the ROLLBACK WORK statement.
Transaction begins.
BEGIN WORK
statement-1
SAVEPOINT :MyVariable
statement-2
statement-3
Work of statements 2 and 3 is undone.
ROLLBACK WORK
TO :MyVariable
Work of statement 1 is committed; transaction ends.
COMMIT WORK
|