Transaction Leak

TomBascom

Curmudgeon
More seriously you are probably referring to "transaction scope" and the unintended consequences of poor control of transaction scope.

For instance (very bad sample code follows):
Code:
/* badcode.p
 */

find first customer.
update name.
run something.p

In this case the transaction is scoped to the entire "badcode.p" procedure. You might say that it "leaks" to something.p. And because the scope is the entire procedure an unhandled error in something.p that returns to badcode.p will result in both something.p and badcode.p having their transactions rolled back.
 

TomBascom

Curmudgeon
Good control of transaction scope is closely related to good control of record scope and looks more like this:

Code:
/* bettercode.p
 */

define variable cNum  as integer    no-undo.
define variable cName as character no-undo.

procedure updName:

  define input parameter xNum  as integer    no-undo.
  define input parameter xName as character no-undo.

  define buffer customer for customer.

  do for customer transaction:
    find customer exclusive-lock where custNum = xNum no-error.
    if available( customer ) then customer.name = xName.
  end.

  return.

end.

update cNum cName.

run updName( cNum, cName ).

run something.p
 
Top