Try OpenEdge Now
skip to main content
Developing WebSpeed Applications
Controlling Database Transactions : SpeedScript components and database transactions : Subprocedures
 

Subprocedures

If you start a database transaction in a main procedure, that transaction remains active even while the main procedure runs called procedures. In the following figure, p-txn11.p runs p-txn11a.p within a database transaction.
Figure 20. DB transactions and subprocedures
The REPEAT block p-txn11.p procedure is the transaction block for that procedure: it contains a direct update to the database. The database transaction begins at the start of each iteration of the REPEAT block and ends at the end of each iteration. That means when the p-txn11.p procedure calls the p-txn11a.p procedure, the transaction is still active. So all the work done in the p-txn11a.p subroutine is part of the transaction started by the main procedure, p-txn11.p.
If a system error occurs while you are processing orders for a customer, WebSpeed undoes all the order processing work you have done for that customer, as well as any changes you made to the customer record itself.