SJaka
SJaka

Reputation: 840

Progress-4gl: How does transaction scope apply to external program calling?

I need some help understanding transaction scoping for procedures/programs outside the current program.

Suppose I've three program, program A, program B and program C. Inside program A, I've a procedure that has some lines in it wrapped inside a do transaction (not strongly typed) block. Within that do transaction block, it calls another Program B. Upon return from program B there is an undo, leave command. Within the same transaction block, it calls program C and has an undo, leave after this call too.

My question is, if within the transaction block, program B executes without errors, but program c returned an error, will the undo,leave after program C call will also undo transactions that happened inside program B?

Procedure do_something:
  some processing....
  do transaction:
    error-message = "".
    {run programB.p}
    if error-message <> "" then undo, leave.
  
    some further processing...
  
    error-message = "".
    {run programC.p}
    if error-message <> "" then undo, leave.
  end. /* end of do transaction */
end procedure.

Upvotes: 2

Views: 1428

Answers (2)

Tom Bascom
Tom Bascom

Reputation: 14020

Yes. In the example that you describe everything gets rolled back.

It is not so much that it is "extended" per se but just that the transaction includes everything that happens in that session from the point in time when it is enabled all the way until it is either committed or rolled back. Internal procedures, external procedures, user defined functions, methods of classes, trigger code etc.

"In that session" is important - if you call a procedure on an app server that activity is NOT included since it is its own process with its own distinct transaction context.

When app servers are involved things get messy. The original caller has no (built-in) capability to know what to roll back in the called app server session. The app server call could return an error that causes the caller to roll back if it encounters problems but the caller could also decide to trap and ignore that error.

Upvotes: 6

Mike Fechner
Mike Fechner

Reputation: 7192

Yes. Everything happening in the transaction block will be undone.

Upvotes: 4

Related Questions