Try OpenEdge Now
skip to main content
Developing WebSpeed Applications
Controlling Database Transactions : Understanding the scope of database transactions : Subtransactions
 

Subtransactions

A subtransaction is started when a database transaction is already active and WebSpeed encounters a subtransaction block. If an error occurs during a subtransaction, all the work done since the beginning of the subtransaction is undone. Subtransactions can be nested within other subtransactions.
The following are subtransaction blocks:
*A procedure block that is run from a transaction block in another procedure.
*Each iteration of a FOR EACH block nested within a transaction block.
*Each iteration of a REPEAT block nested within a transaction block.
*Each iteration of a DO TRANSACTION, DO ON ERROR, or DO ON ENDKEY block. (These blocks are discussed later in this chapter.)
The following table shows when database transactions and subtransactions are started.
Table 15. Starting database transactions and subtransactions
Type of block
Inactive transaction
Active transaction
DO transaction
FOR EACH transaction
REPEAT transaction
Any DO ON ENDKEY, DO ON ERROR, FOR EACH, REPEAT, or procedure block that directly contains statements that modify database fields or records or that read records using an EXCLUSIVE-LOCK.
Starts a transaction
Starts a subtransaction
Any FOR EACH, REPEAT, or procedure block that does not directly contain statements that either modify the database or read records using an EXCLUSIVE-LOCK.
Does not start a subtransaction or a transaction
Starts a subtransaction
Note that data handling statements that cause WebSpeed to automatically start a transaction for a database table do not cause WebSpeed to automatically start a transaction for a work table or temporary table.