WebSpeed
Developer’s Guide


Understanding the Scope of DB Transactions

How does WebSpeed know where to start the database transaction and how much work to undo or back out? The following transaction blocks start a database transaction if one is not already active:

Directly updating the database means that the block contains at least one statement that can change the database. CREATE, DELETE, and UPDATE are examples of such statements.

If a block contains FIND or FOR EACH statements that specify EXCLUSIVE-LOCK, and at least one of the FIND or FOR EACH statements is not embedded within inner transaction blocks, then the block is directly reading records with EXCLUSIVE-LOCK.

Note that DO blocks do not automatically have the transaction property. Also, if the procedure or database transaction you are looking at is run by another procedure, you must check the calling procedure to determine whether it starts a database transaction before the RUN statement.

Once a database transaction is started, all database changes are part of that transaction, until it ends. Each user of the database can have just one active transaction at a time. The procedure in Figure 9–4 has two blocks: the procedure block and the REPEAT block.

Figure 9–4: Database Transaction Scope

The procedure block has no statements directly in it that are not contained within the REPEAT block. The REPEAT block contains a CREATE statement that lets you add order records to the database. Because the REPEAT block is the outermost block that contains direct updates to the database, it is the transaction block.

At the start of an iteration of the REPEAT block, WebSpeed starts a database transaction. If any errors occur before the END statement, WebSpeed backs out any work done during that transaction.

Note that data-handling statements that cause WebSpeed to automatically start a database transaction for a regular table will not cause WebSpeed to automatically start a transaction for a work table or temporary table.

Figure 9–5 shows a procedure with multiple transactions.

NOTE: This example uses the GetField method procedure where WebSpeed usage recommends the get-field( ) API function. See the online AppBuilder Help for more information.

Figure 9–5: Multiple DB Transactions in a Procedure

This procedure has four blocks:


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095