I'm looking for an answer that satisfies my need on both SQL Server and MySQL.
I have a small, custom audit table that I will be writing to through triggers on various tables. There are situations where I would like to bypass those triggers. I know that I can make a column on the tables and use it as a sort of flag for the trigger, but I'm hoping to find something that generates less clutter.
Is it possible to prevent a trigger from being called using a variable in my statement or some other query side thing?
EDIT: To clarify, I'm not expecting an actual trigger/query that works on both platforms. I'm looking for a solution that fits the desired goal of not having to use an extra column in each table.
INSTEAD OF
andAFTER
triggers, MySQL hasBEFORE
andAFTER
. There are numerous other differences that make the chance of writing a trigger that works in both platforms, almost 0. having said that, your idea of an extra column (or something else that someone else may come up with) may work for both worlds - but the implementation details will differ.CONTEXT_INFO
within the trigger. Both these methods would avoid adding a column to the table.