ALLBASE/SQL Reference Manual (36216-90216)

314 Chapter10
SQL Statements A - D
BEGIN WORK
The following sequences of statements must be in the same transaction in a program:
PREPARE and EXECUTE
PREPARE, DESCRIBE, OPEN, FETCH USING DESCRIPTOR, EXECUTE, and CLOSE
OPEN, FETCH, DELETE WHERE CURRENT, UPDATE WHERE CURRENT, and CLOSE (unless
KEEP CURSOR is used)
To end your transaction, you must issue a COMMIT WORK or ROLLBACK WORK statement.
Otherwise, locks set by your transaction are held until a STOP DBE, DISCONNECT,
RELEASE, or TERMINATE USER statement is processed.
If the maximum number of concurrent DBEnvironment transactions has been reached,
the application is placed on a wait queue. If the application times out while waiting, an
error occurs. Default and maximum timeout values are specified at the DBEnvironment
level. To set a timeout for a session or transaction, use the SET USER TIMEOUT
statement. Refer to Chapter 2 , “Using ALLBASE/SQL,” "Setting Timeout Values"
section for further information.
To avoid lock contention in a given DBEnvironment, do not allow simultaneous
transactions when performing data definition operations.
When using RC or RU, you should verify the existence of a row before you issue an
UPDATE statement. In application programs that employ cursors, you can use the
REFETCH statement prior to updating. REFETCH is not available in ISQL. Therefore, you
should use caution in employing RC and RU in ISQL if you are doing updates.
If the FILL or PARALLEL FILL option has already been set for the session with a SET
SESSION statement, and you do not want either of these options in effect for a given
transaction, specify NO FILL in the transaction's BEGIN WORK statement.
Authorization
You do not need authorization to use the BEGIN WORK statement.
Examples
1. BEGIN WORK and ROLLBACK WORK
Transaction begins:
BEGIN WORK CS
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 and the transaction ends:
COMMIT WORK