Triggers interact with CL commands in several ways.
Save/Restore Base File (SAVOBJ/RSTOBJ)
- The Save/Restore function will not search for the trigger program during
save/restore time. It is your responsibility to manage the program. During
run time, if the system has not restored the trigger program, the system returns
a hard error with the trigger program name, physical file name, and trigger
event.
- If the entire library (*ALL) is saved and the file and all
trigger programs are in the same library and they are restored to a different
library, then all the trigger program names are changed in the file to reflect
the new library.
Save/Restore Trigger Program (SAVOBJ/RSTOBJ)
- If you restore the trigger program in a different library, the change
operation fails because the trigger program is not in the original library.
The error returns the trigger program name, physical file name, and trigger
event information.
There are two ways to recover in this situation:
- Restore the trigger program to the same library
- Create a new trigger program with the same name in the new library
Delete File (DLTF)
- If a file is deleted, the association between
this file and its trigger programs are removed. For system triggers, the trigger
programs remain on the system.
Copy File (CPYF)
- If a to-file associates with an insert trigger, each inserted record calls
the trigger program.
- If a to-file associates with a delete trigger program and the CPYF command
specifies MBROPT(*REPLACE), the copy operation fails.
- Copy with CREATE(*YES) does not propagate the trigger information
Create Duplicate Object (CRTDUPOBJ)
If TRG(*NO) is specified, triggers will not be duplicated
in the new file. If TRG(*YES) is specified, triggers will be duplicated. The
following rules describe how triggers are duplicated:
- When a physical file and its trigger program are originally in the same
library, the trigger program library will always be changed to the new library,
even if the trigger program does not exist in the new library. In addition,
the following rules apply:
- If the CRTDUPOBJ command is duplicating both the physical file and its
trigger program to a new library, then the new trigger program will be associated
with the new physical file.
- If the CRTDUPOBJ command is duplicating only the physical file, then the
trigger program with the same program name in the TO library will be associated
with the new physical file. This is true even if there is no trigger program
by that name in the TO library. The library of the trigger program will be
changed.
- If the CRTDUPOBJ command is duplicating only the trigger program, then
the new trigger program will not be associated with any physical files.
- When a physical file and its trigger program are originally in different
libraries:
- The old trigger program will be associated with the new physical file.
Even if the new physical file is duplicated to the same library as the trigger
program, the old trigger program will still be associated with the new physical
file.
- A trigger program cannot be added if the program is in the QTEMP library.
For database files, the CRTDUPOBJ command attempts to locate the trigger program
in the TO library. If the CRTDUPOBJ command is used with QTEMP specified as
the new library, CRTDUPOBJ attempts to create as much of the object as possible.
The file is created, but the trigger cannot be added, so the file remains
in QTEMP without a member.
Clear Physical File Member (CLRPFM)
- If the physical file is associated with a delete trigger, the CLRPFM operation
fails.
Initialize Physical File Member (INZPFM)
- If the physical file is associated with an insert trigger, the INZPFM
operation fails.
FORTRAN Force-End-Of-Data (FEOD)
- If the physical file is associated with a delete trigger, the FEOD operation
fails.
Apply Journaled Changes or Remove Journaled Changes (APYJRNCHG/RMVJRNCHG)
- If the physical file is associated with any type of trigger, the APYJRNCHG
and RMVJRNCHG operations do not call the trigger program. Therefore, you must
make sure to have all the files within the trigger program journaled. Then,
when using the APYJRNCHG or RMVJRNCHG command, make sure to specify all of
these files. This ensures that all the physical file changes for the application
program and the trigger programs are consistent.
Note: If any trigger program
functions do not relate to database files and cannot be explicitly journaled,
send journal entries to record relevant information. Use the Send Journal
Entry (SNDJRNE) command or the Send Journal Entry (QJOSJRNE) API. Use this
information during database file recovery to ensure consistency.