We have observed that when we update, insert, or delete a record or a set of records in a file or a table some associated programs known as triggers get fired by the database manager. How can I identify what are all files in a library has associated trigger programs?
To check triggers on a file, run the command Print trigger programs (
PRTTRGPGM
). It generates a report that includes all physical file triggers on your AS400 system.PRTTRGPGM
command takes two input parameters, namely library and changed report only. We can pass the values in the library parameter as *LIBL, *USRLIBL, *CURLIB, *ALL, *ALLUSR, or Library name. In the changed report-only parameter, the default value is *NO i.e. full and changed reports will be printed. You can also pass *YES, which means only the changed report will be printed.Once you run the
PRTTRGPGM
command with specified parameter values, a trigger program spool file QPSECTRG in your job gets generated. You can access it using the WRKSPLF command.In the report, you will see specified library info that you passed in the first parameter, other information as a library, the file on which the trigger program is attached, ASP device, name of trigger, type, trigger program library, and name, time, event, condition, allow repeated change.
You can also use the
DSPFD
command outfile to check triggers on a file. Run the following command from the command line to create an outfile in the qtemp library.DSPFD FILE(TESTLIB/FILENAME)
TYPE(*TRG)
OUTPUT(*OUTFILE)
OUTFILE(QTEMP/OutFileName)
In the outfile you will receive a row when there is any trigger program associated with this file, otherwise, the outfile will be empty.
We can use SQL view
SYSTRIGGER
present in the QSYS2 library to check triggers on a file. We can find all the information about triggers in this view, many columns exist in this view. However, will query some of the columns that are similar to what the DSPFD command returns in an outfile. Selecting short field names inqsys2/systrigger
or selecting long field names in
qsys2/systrigger