Unanswered: How to Block triggers while synchronisation?
Any body knows how to block Trigger action while synchronisation?
I am doing Audit Trailing by using Triggers and some History tables. These triggers will update each and every updation in the table to the related history table. I want to block these triggers while doing synchronisation.
You could modify the trigger to first check which userid is doing the dml which fires the trigger. If it is the userid running the synchronization then exit the trigger. Otherwise continue to execute the rest of the trigger code.
You can block all the triggers from one table with (ASE 12.0):
ALTER TABLE mytable DISABLE TRIGGER
or just one trigger with:
ALTER TABLE mytable DISABLE TRIGGER mytrigger
Then you enable again with:
ALTER TABLE mytable ENABLE TRIGGER
ALTER TABLE mytable ENABLE TRIGGER mytrigger
If you want to know the state of all triggers in a databases, you can use this select:
SELECT name Table_Name,
WHEN (sysstat2 & 1048576) = 1048576 THEN "Disable"
WHEN (sysstat2 & 2097152) = 2097152 THEN "Disable"
WHEN (sysstat2 & 4194304) = 4194304 THEN "Disable"
WHERE type = "U"
AND ( instrig <> 0
OR updtrig <> 0
OR deltrig <> 0 )