W0lfw00ds
W0lfw00ds

Reputation: 2096

Transaction and functions

We are using functions in a single .p-file, like the following:

myTest.p

BLOCK-LEVEL ON ERROR UNDO, THROW.

FUNCTION secondFunc RETURNS LOG ():
   UNDO, THROW NEW Progress.Lang.AppError("ERROR HAPPENED, UNDO ALL!").
END FUNCTION.

FUNCTION firstFunc RETURNS LOG ():
   secondFunc().
END FUNCTION.

FUNCTION starter RETURNS LOG ():

   /* start transaction */
   DO TRANSACTION:
      firstFunc().
   END.
END FUNCTION.

/* start execution of the function tree */
starter().

CATCH err AS Progress.Lang.Error:
   RUN WRITE_log(err:GetMessage(1)).
   MESSAGE err:GetMessage(1) VIEW-AS ALERT-BOX.
   UNDO, RETURN ERROR.
END.

According to this code, does the Transaction undo all changed done inside it in starter()-function? Or do we need to pass some kind of handle to all functions inside the Transaction so it can be "undone"?

Upvotes: 1

Views: 815

Answers (1)

Tom Bascom
Tom Bascom

Reputation: 14020

If an "outer" transaction rolls back then all sub transactions, including those in called code, will also roll back.

Upvotes: 3

Related Questions