ALLBASE/SQL Reference Manual (36216-90216)

Chapter 2 85
Using ALLBASE/SQL
Managing Transactions
Starting Transactions
A transaction is initiated with either an implicit or explicit BEGIN WORK statement. An
implicit BEGIN WORK statement is issued by ALLBASE/SQL when any SQL statement is
executed, except for the following:
Explicit BEGIN WORK statements are recommended, for the following reasons:
Explicit BEGIN WORK statements make your code easier to read.
You must use an explicit BEGIN WORK statement to specify a non-default isolation level
or transaction priority.
You might unintentionally lock out other users by the default isolation level of an
implicit BEGIN WORK.
Since nested transactions are not allowed, an error is generated if a session with an active
transaction issues a BEGIN WORK statement. The first transaction must end before another
transaction can begin.
Ending Transactions
A transaction ends when either a COMMIT WORK or a ROLLBACK WORK statement is issued.
All locks held by the session are released when the transaction ends, except those held by a
kept cursor.
Using COMMIT WORK
Issue the COMMIT WORK statement when the transaction is successful and you want the
changes made permanent. Unlike the BEGIN WORK and ROLLBACK WORK statements, the
COMMIT WORK statement is never issued automatically by ALLBASE/SQL. You must issue
the COMMIT WORK explicitly for each transaction. The COMMIT WORK statement causes the
contents of the log buffer to be written to a log file. If rollforward recovery is needed at a
later time, the transactions recorded in the log file are applied to the database.
ASSIGN BEGIN ARCHIVE BEGIN DECLARE SECTION
BEGIN WORK CHECKPOINT COMMIT ARCHIVE
COMMIT WORK CONNECT DECLARE VARIABLE
DISABLE AUDIT LOGGING ENABLE AUDIT LOGGING END DECLARE SECTION
GOTO IF INCLUDE
PRINT RAISE ERROR RELEASE
RESET RETURN ROLLBACK TO SAVEPOINT
ROLLBACK WORK SET SESSION EX SET TIMEOUT
SET TRANSACTION START DBE STOP DBE
SQLEXPLAIN TERMINATE USER WHENEVER
WHILE