Exactly When Are Triggers Invoked

LANSA for i

Exactly When Are Triggers Invoked?

Before Open / Close

Before open/close triggers are invoked immediately before an attempt is made to open or close a file (or a view of it).

A before open trigger is invoked when a file or a view is opened and or another view has not already opened the file.

This means that if your logic is "Open View 1", then "Open View 2" (where view 1 and view 2 are both based on the same file) then the trigger would be invoked when you open view 1, but not when you open view 2.

A before close trigger is invoked when a file or a view is closed and another view still does not have the file open.

This means that if your logic is "Close View 1", then "Close View 2" (where view 1 and view 2 are both based on the same file) then the trigger would be invoked when you close view 2, but not when you closed view 1.

After Open / Close

Is invoked identically to the "before" options but immediately after a successful attempt has been made to close the file.

Before Read

Is invoked immediately before an attempt is made to read a record from a file. Before input triggers have no access to "information" from the file (because the information has not been input yet) so their use should be considered carefully. Access to the key(s) being used to access the file is not possible in this mode so do not design triggers based on this premise.

After Read

Is invoked after a record has been successfully read from a file and just before the details of the record are passed back to the invoking function. Any virtual field logic has been completed by this stage.

Before Insert

Is invoked immediately before an attempt is made to insert a new record into a file. Please note the following:

  • The trigger is run even if the requester uses CHECK_ONLY(*YES)
  • The insert may still fail (e.g.: duplicate key error). Before insert triggers should not perform database changes. If database changes are to be done move the trigger into the "after insert" position instead.
  • All virtual logic has been completed when the trigger is invoked.

After Insert

Is invoked immediately after a new record has been inserted into a file. Please note the following:

  • The trigger is not run when the requester uses CHECK_ONLY(*YES)
  • At the time of invocation all batch control logic has been executed.
  • If AUTOCOMMIT is used then the commit is issued before the trigger is invoked.

Before Update

Is invoked immediately before an attempt is made to update an existing record in a file. Please note the following:

  • The trigger is run even if the requester uses CHECK_ONLY(*YES)
  • The update may still fail (e.g.: duplicate key error). Before update triggers should not perform database changes. If database changes are to be done move the trigger into the "after update" position instead.
  • All virtual logic has been completed when the trigger is invoked.

After Update

Is invoked immediately after an existing record has been updated in a file. Please note the following:

  • The trigger is not run when the requester uses CHECK_ONLY(*YES)
  • At the time of invocation all batch control logic has been executed.
  • If AUTOCOMMIT is used then the commit is issued before the trigger is invoked.

Before Delete

Is invoked immediately before an attempt is made to delete an existing record from a file. Please note the following:

  • The trigger is run even if the requester uses CHECK_ONLY(*YES)
  • The delete may still fail (even though very unlikely). Before delete triggers should not perform database changes. If database changes are to be done move the trigger into the "after delete" position instead.

After Delete

Is invoked immediately after an existing record has been deleted from a file. Please note the following:

  • The trigger is not run when the requester uses CHECK_ONLY(*YES)
  • At the time of invocation all batch control logic has been executed.
  • If AUTOCOMMIT is used then the commit is issued before the trigger is invoked.