Sunday, March 20, 2011

MySql Triggers - Can a trigger stop ALL dml?

Hi All,

Is it possible to create a trigger on a table that is initiated when ANY dml is performed on the table?

For example -- I need to ensure that no insert/update/delete statements can be run on the weekend. So, instead of writing:

CREATE TRIGGER DENY_DML_1 BEFORE INSERT...

CREATE TRIGGER DENY_DML_2 BEFORE UPDATE...

CREATE TRIGGER DENY_DML_3 BEFORE DELETE...

...is it possible to write one trigger to rule them all?

Many thanks in advance! ~Daniel

From stackoverflow
  • No. From the documentation:

    *trigger_event* indicates the kind of statement that activates the trigger. The *trigger_event* can be one of the following: INSERT... UPDATE... DELETE...

    ajax81 : Thank you for confirming. I was pretty sure I was going to have to write a trig for each event, but I thought I'd get community feedback before going the extra mile. Thank you!

0 comments:

Post a Comment