Methods to Enable/Disable Triggers
Use the Change Physical File Trigger (CHGPFTRG) command or the ALTER TRIGGER SQL statement. Using CHGPFTRG Command; you can enable or disable named triggers or all triggers for a file using the CHGPFTRG command. Using ALTER TRIGGER SQL Statement; you can also disable triggers using the ALTER TRIGGER SQL statement. The third option is using System i Navigator; you can enable or disable triggers.
Disabling triggers causes the trigger program not to be called when a change operation occurs to the physical file.
CHGPFTRG (Change Physical File Trigger) Command
Use this command to enable or disable specific named triggers or all triggers associated with a physical file.
-
STATE(*DISABLED)→ disables the trigger. STATE(*ENABLED)→ enables the trigger.
ALTER TRIGGER SQL Statement
You can control trigger state directly in SQL.
ALTER TRIGGER MYTRIGGER ENABLE;
System i Navigator (ACS GUI Tool)
Provides a graphical interface to manage triggers. You can right-click on the file, view its triggers, and enable/disable them without using command line.
Remember: Disabling a trigger simply pauses it—the program won’t run on inserts, updates, or deletes. Removing is different: use RMVPFTRG to break the link entirely between file and program. And don’t forget, a single database file can hold up to 300 triggers, with multiple firing before or after each operation.
Quick Summary
- Use CHGPFTRG for command-line control.
- Use ALTER TRIGGER for SQL-based control.
- Use System i Navigator for GUI-based control.
- Disabling ≠Removing ! Disabling just pauses the trigger program, while removing deletes the association.
