Execute Clause for the Add Program Command

Use the execute clause to specify when the program should be executed. If the execute clause is not used, immediate is assumed.

Immediate execution means that the program runs within the current transaction, and therefore can influence the success or failure of the transaction, and that all the program’s database updates are subject to the outcome of the transaction.

Deferred execution means that the program is cued up to begin execution only after the outer-most transaction is successfully committed. A deferred program will not execute at all if the outer transaction is aborted. A deferred program failure affects only the new isolated transaction in which it is run (the original transaction from which the program was launched will have already been successfully committed).

For example, to defer the execution of the “Roll up Cost” program:

modify program “Roll up Cost” execute deferred;

However, there are a number of cases where deferring execution of a program does not make sense (such as when it is used as a trigger check, for example). In these cases the system will execute the program immediately, rather than deferring it until the transaction is committed.

A program’s execution can be deferred for these cases:

  • Stand-alone program
  • Method
  • Trigger action
  • State action

Deferred execution will be ignored for these cases:

  • Trigger check
  • Trigger override
  • State check
  • Range program

In this case, a program’s execution is always deferred:

  • Format edit/view/print

A program downloaded to the Web client for local execution (for more information, see Downloadable Clause for the Add Program Command) can be run only in a deferred mode. Therefore, if you use the downloadable option, program execution is automatically deferred.

The Usesexternalinterface clause continues to be supported for historical reasons. Scripts and programs that use this clause result in Program objects that have the execute flag set to deferred and the downloadable flag set.