Command reference / db
ADDPFTRG
Add Physical File Trigger
Associates a trigger program with a physical file. Select the record operation and whether the trigger runs before or after it.
Allowed environments: *ALL.
Positional parameters: 4.
Parameters
FILE
File
Sets the physical file to which this trigger program is added. The file must exist on the system.
name (physical file)- Enter the name of the file to which the trigger program is added.
*LIBL- Look in the thread's library list.
*CURLIB- Look in the current library, falling back to QGPL.
name (library)- Enter the name of the library to be searched.
Qualified parts (object, then library; write LIBRARY/OBJECT)
File
File
Library
Library
Suggested / special values:
*LIBL, *CURLIB
TRGTIME
TRGTIME
Sets the time when the trigger program is called.
Allowed values:
*BEFORE, *AFTER
*BEFORE- The trigger program is called before the change operation on the specified physical file.
*AFTER- The trigger program is called after the change operation on the specified physical file.
TRGEVENT
TRGEVENT
Sets the event (the change operation to the physical file) that calls the trigger program. Only one event can be specified for each command issued.
Allowed values:
*INSERT, *DELETE, *UPDATE, *READ
*INSERT- An insert operation calls the trigger program. Note: If the physical file is not read and write capable, the *INSERT value cannot be specified.
*DELETE- A delete operation calls the trigger program. Notes: If the physical file is not read and delete capable, the *DELETE value cannot be specified.
*UPDATE- An update operation calls the trigger program. Notes: If the physical file is not read and update capable, the *UPDATE value cannot be specified.
*READ- A read operation calls the trigger program. Note: If the physical file is not read capable, the *READ value cannot be specified.
PGM
Pgm
Sets the program that is called when the specified event occurs on the physical file. The program must exist on the system and be of object type *PGM. Note: The special values *LIBL and *CURLIB are the values of the job running when the trigger program is added.
name (program)- Enter the name of the program to be called when the specified event occurs on the specified physical file.
*LIBL- Look in the thread's library list.
*CURLIB- Look in the current library, falling back to QGPL.
name (library)- Enter the name of the library to be searched.
Qualified parts (object, then library; write LIBRARY/OBJECT)
Pgm
Pgm
Library
Library
Suggested / special values:
*LIBL, *CURLIB
RPLTRG
RPLTRG
Controls whether an existing trigger is replaced by the trigger to be added when the triggers have the same trigger event and trigger time.
Allowed values:
*NO, *YES
*NO- The existing trigger is not replaced.
*YES- The existing trigger is replaced. If *GEN was specified for the trigger name and the time and event match a single entry, the trigger will be replaced.
TRG
TRG
Enter the name of the trigger being added.
Suggested / special values:
*GEN
*GEN- The system generates a trigger name.
character-value- Enter the name of the trigger. The trigger name must be unique to the library. The trigger name is used to distinguish triggers with the same time and event values.
TRGLIB
Trigger library
Sets the library for the trigger being added.
Suggested / special values:
*FILE, *CURLIB
*FILE- The library for the file specified on the FILE parameter is used.
*CURLIB- The current library for the job is used. If no library is specified as the current library for the job, the QGPL library is used. Note: The special value *CURLIB is the value of the job running when the trigger program is added.
name- Enter the name of the library to be used.
ALWREPCHG
ALWREPCHG
Controls whether repeated changes to a record within a trigger or any subsequent trigger(s) called while the trigger program is running are allowed.
Allowed values:
*NO, *YES
*NO- Repeated changes to a record within a trigger or any subsequent trigger(s) called are not allowed.
*YES- Repeated changes to a record within a trigger or any subsequent trigger(s) called are allowed.
THDSAFE
THDSAFE
Controls whether the trigger program is threadsafe. This is intended for documentation purposes only. It may be used in determining the MLTTHDACN value, but there is no direct relationship between the THDSAFE and MLTTHDACN keywords.
Allowed values:
*UNKNOWN, *NO, *YES
*UNKNOWN- The threadsafe status of the trigger program is not known.
*NO- The trigger program is not threadsafe.
*YES- The trigger program is threadsafe.
MLTTHDACN
MLTTHDACN
Sets the action to take when the trigger program is called in a multithreaded job. The THDSAFE attribute of the trigger program can be used in determining the action, however, there is no direct relationship between the THDSAFE and MLTTHDACN keywords.
Allowed values:
*SYSVAL, *MSG, *NORUN, *RUN
*SYSVAL- Use the QMLTTHDACN system value to determine the action to take.
*MSG- Run the trigger program in a multithreaded job, but send a diagnostic message.
*NORUN- Do not run the trigger program in a multithreaded job. Send an escape message.
*RUN- Run the trigger program in a multithreaded job.
TRGUPDCND
TRGUPDCND
Sets the condition under which an update event calls the trigger program. Note: This parameter applies only when *UPDATE is specified for the Trigger event (TRGEVENT) parameter.
Allowed values:
*ALWAYS, *CHANGE
*ALWAYS- The trigger program is called whenever a record is updated, whether or not a value changes.
*CHANGE- The trigger program is called only when a record is updated and a value is changed.
Examples
ADDPFTRG FILE(EMP) TRGTIME(*AFTER) TRGEVENT(*INSERT) PGM(LIB2/INSTRG)
Adds a trigger with trigger program INSTRG in library LIB2 to the physical file named EMP. When an insert operation occurs on the EMP file, the program INSTRG is called after the insert operation.
ADDPFTRG FILE(EMP) TRGTIME(*AFTER) TRGEVENT(*INSERT) PGM(LIB2/INSTRG)
ADDPFTRG FILE(EMP) TRGTIME(*AFTER) TRGEVENT(*UPDATE) PGM(LIB2/INSTRG)
These two commands add triggers to call the trigger program INSTRG in library LIB2 when an insert or update operation occurs on the EMP file.
ADDPFTRG FILE(EMP) TRGTIME(*BEFORE) TRGEVENT(*UPDATE) PGM(LIB2/UPDTRG) TRGUPDCND(*CHANGE)
The trigger program UPDTRG in library LIB2 is called before a value for a field of a record in the EMP file changes during an update.
ADDPFTRG FILE(EMP) TRGTIME(*BEFORE) TRGEVENT(*UPDATE) PGM(LIB2/NEWPGM) RPLTRG(*YES) TRGUPDCND(*CHANGE)
The trigger program NEWPGM being added to the file EMP has the same trigger time (*BEFORE) and trigger event (*UPDATE) as the trigger program UPDTRG that was added in Example 3.
ADDPFTRG FILE(EMP) TRGTIME(*BEFORE) TRGEVENT(*UPDATE) PGM(LIB2/NEWPGM) RPLTRG(*YES) TRGUPDCND(*ALWAYS)
The trigger added in Example 4 that calls the trigger program NEWPGM only is the values are changed, is replace by a trigger that always calls the trigger program NEWPGM regardless of the values.
Generated from os/cl/catalog/ADDPFTRG.json and os/cl/help/ADDPFTRG.json.