Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2013
    Posts
    1

    Disabling triggers' firing

    Hi,
    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 ??
    Cheesrs,
    timo
    Last edited by talja; 02-12-13 at 07:49.

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,844
    Disabling or enabling the trigger may impact UI (non-replication) table updates.

    Why not
    1. Add a table to hold the replication update user's logon name for the replication updates.
    2. 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.
    3. 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...
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •