transaction block(1) — Commands
Digital
NAME
BLOCK WITH TRANSACTION - statement demarcating a set of operations that execute in the same transaction
SYNOPSIS
[<label-name>:] BLOCK WITH TRANSACTION
[ <label-name-1>: ] { <statement> ; } [ ... ]
END BLOCK [<label-name>] ;
[ EXCEPTION HANDLER IS
[ <label-name-2>: ] { <statement> ; } [ ... ]
END EXCEPTION HANDLER
] ;
PARAMETERS
•label-name
An internal unqualified identifier associated with the beginning of the transaction block, for use in flow control operations within the task. The label name specified on the END BLOCK must be the same as the label name specified at the beginning of the BLOCK.
•label-name-1
An internal unqualified identifier associated with a statement within the transaction block, for use in flow control operations within the transaction block. See the goto man page for rules on using statement labels.
•label-name-2
An internal unqualified identifier associated with a statement within the exception handler, for use in flow control operations within the exception handler. See the goto man page for rules on using statement labels.
•statement
A statement prescribes one or more operations to be performed. Some statements must be used inside a transaction block. See the description of the noncomposable task in the task_definition man page. If a statement that must be used inside a transaction block appears in one of the following places, it must be enclosed by a transaction block:
oWithin a noncomposable task
oWithin the exception handler of a transaction block
oWithin the exception handler of a statement block outside a transaction block
DESCRIPTION
ACMSxp software implicitly starts a transaction before the first transactional resource is accessed. A transaction block cannot be nested within another transaction block.
ACMSxp software implicitly commits a transaction at END BLOCK unless a previous statement contains a commit or a rollback, or unless a transaction exception is generated.
The default execution flow for a transaction block is WITH COMMIT.
The normal execution flow for a transaction block is:
1.Starts a transaction when the first transactional operation within the block starts.
2.Executes the statement list. If the statement list completes with explicit EXIT BLOCK flow control that does not specify ROLLBACK, normal execution continues.
3.Commits the transaction.
4.Completes the transaction block with default flow control.
Deviations from the normal execution flow occur when:
oThe statement list completes with explicit EXIT BLOCK flow control that specifies ROLLBACK.
The transaction rolls back and the transaction block completes with default flow control.
oThe statement list completes with explicit EXIT TASK or GO TO flow control that does not specify ROLLBACK.
The transaction commits and the transaction block completes with the same explicit flow control.
oThe statement list completes with explicit EXIT TASK or GO TO flow control that specifies ROLLBACK.
The transaction rolls back and the transaction block completes with the same explicit flow control.
oThe statement list completes with an exception, in which case the transaction is rolled back. The processing depends on the types of exceptions that can occur:
-Fatal exception
The transaction block completes with the exception.
-Transient transaction exception
∗If the task is restartable and the retry limit is not exceeded, the transaction block executes again.
∗If the task is not restartable or the retry limit is exceeded, and, if there is an exception handler, the exception handler executes.
∗If there is no exception handler, the transaction block completes with a permanent transaction exception.
-Permanent transaction or nontransaction exception
If there is an exception handler, the exception handler executes. If there is no exception handler, the transaction block completes with a permanent transaction exception.
An exception handler can complete with:
oDefault flow control
The transaction block block completes with the default flow control.
oExplicit flow control
The transaction block completes with the same explicit flow control.
oException
The transaction rolls back and the transaction block completes with that exception.
See the exception man page for a description of how transaction exceptions are handled.
RELATED INFORMATION
Syntax: exception(1), exception_handler(1), exit_block(1), exit_task(1), goto(1), statement(1)