If I have a trigger BEFORE UPDATE on a table. How can I throw an error that prevents the update on that table?
+3
A:
Here is one hack that might work. Isn't clean, but it looks like it might work:
Essentially you just try to update a column that doesn't exist.
Justin
2008-08-01 13:02:51
+1
A:
I've been using the approach that Justin linked for a while now. Works great, but definitely hackish.
As that link states, eventually MySQL plans to have real exception raising via the SQL SIGNAL and RESIGNAL statements.
P.S. Justin: for convenience, you may want to make that URL an actual hyperlink; or just wait for this: http://stackoverflow.uservoice.com/pages/general/suggestions/14397
Liron Yahdav
2008-08-01 15:08:58
A:
What does your trigger do? Is it something that could just as easily be wrapped in the update's transaction?
That could save you hassle down the line.
Rob Allen
2008-08-02 15:32:17