Preventing Triggers from Overriding Each Other
When you activate multiple triggers with an UPDATE statement, a trigger can possibly override the changes that an earlier trigger made. If you do not want the trigger actions to interact, you can split the UPDATE statement into multiple UPDATE statements, each of which updates an individual column.
As another alternative, you can create a single update trigger
for all columns that require a trigger action. Then, inside the trigger
action, you can test for the column being updated and apply the actions
in the desired order. This approach, however, is different from having
the database server apply the actions of individual triggers, and
it has the following disadvantages:
- If the triggering UPDATE statement sets a column to the current value, you cannot detect the UPDATE, so the trigger action is skipped. You might wish to execute the trigger action, even though the value of the column has not changed.
- If the trigger has a BEFORE action, it applies to all columns, because you cannot yet detect whether a column has changed.