I have a trigger_function_a that is triggered before insert or update of field_1 or field_2. I have another trigger_function_b that is triggered before insert or update of field_3 or field_4:
before insert or update of field_1 or field_2 => trigger_function_a
before insert or update of field_3 or field_4 => trigger_function_b
Now, trigger_function_a modifies field_3. Is trigger_function_b supposed to be triggered? I have tried it, but it is not triggered. Why? I have searched all available docs, but I have not found an answer to this.
Please don't care for syntax here. The trigger functions do work for themselves if I modify the fields by myself, e. g. via SQL. All I'm asking here is: Is a trigger function supposed to be fired if another trigger function modifies its fields?
You are correct, trigger_function_bwill not be called in this case.
Look at the documentation:
A column-specific trigger (one defined using the
UPDATE OF column_namesyntax) will fire when any of its columns are listed as targets in theUPDATEcommand'sSETlist. It is possible for a column's value to change even when the trigger is not fired, because changes made to the row's contents byBEFORE UPDATEtriggers are not considered. Conversely, a command such asUPDATE ... SET x = x ...will fire a trigger on columnx, even though the column's value did not change.
The key point here is that a trigger fires if and only if the column appears in the SET list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With