Results 1 to 2 of 2
Thread: Disabling triggers' firing
02-12-13, 08:24 #1Registered User
- Join Date
- Feb 2013
Disabling triggers' firing
we do get input to database both from UI and custom made sql-string-replication. (i.e it feeds tables with statements).
Due this replication we have implemented triggers.
Everything is fine, but now we should find a smart way NOT to fire trigger when input comes from replication.
Anyone with good ideas ??
Last edited by talja; 02-12-13 at 08:49.
02-13-13, 17:42 #2Super Moderator
- Join Date
- Jun 2004
- Arizona, USA
Disabling or enabling the trigger may impact UI (non-replication) table updates.
- Add a table to hold the replication update user's logon name for the replication updates.
- Change your trigger function to first check for the user name presence in the above table. If there is no user in the table, it's a standard table update taking place, so the trigger function continues normally. If there IS a record of this user's name in the above table, replication is taking place; do not perform the code in the function.
- Finally, alter the replication script, so that it writes the current user name to the table above before writing replication records into the main table, and removes the current user name at the end of the script.
This way, while user Bob starts the replication script, if user Fred then used the UI while the replication update was taking place, Fred's updates would be handled normally, even while Bob's replication updates would cause the trigger function to 'short circuit' its normal operation.
The only time this would 'bite you' would be if Bob tried to use the UI at the same time he's running the replication script...