Progress
Programming
Handbook
Making Transactions Larger
In the
p-txn3a.p
procedure, the outermost REPEAT block is the transaction block. That means that when Progress undoes the transaction, it undoes any work performed in the current iteration of the outer REPEAT block. Only the current order is undone, while all other orders are safely stored in the database:
Suppose you wanted, in the event of a system crash, to undo all the orders entered since the start of the procedure. That is, you want to make the transaction block not just one iteration of the outer REPEAT block but rather you want the transaction block to encompass all iterations of the outer REPEAT block. To do this, you use a DO block together with the TRANSACTION option, as in
p-txn4.p
:
The TRANSACTION option on the DO block overrides the default transaction placement. Even though an outermost REPEAT, FOR EACH, or procedure block that contains direct database updates is normally made the transaction block, the TRANSACTION option overrides that default.
Now, Progress starts a transaction at the start of the DO block. That transaction does not end until the end of the DO block or until the transaction is backed out for any reason. Go ahead and run this procedure, entering the following data:
![]()
After you enter all the information for the first order–line, press GO. The procedure prompts you for more order–line information. Press END–ERROR to indicate that there are no more order–lines to enter for this order. The procedure prompts you for the next order.
Enter the following data:
![]()
Before entering the price for order–line 2, press STOP. Progress backs out the transaction, returning you to the procedure editor.
Because the transaction encompasses all iterations of the outer REPEAT block, you would expect that all work done in those iterations would have been backed out. Now, make sure that happened. Run
p-check.p
to check on the orders you entered:
Progress displays the message “order record not on file” for both order number 1020 and 1025. This proves that all the work you did in the procedure has been backed out.
Note that any activity that occurs within a DO block that has no TRANSACTION or ON ERROR phrase in the block header is encompassed in an enclosing transaction or subtransaction and does not result in a transaction or subtransaction being started.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |