Throw an error in MySQL trigger

If I have a trigger BEFORE UPDATE on a table. How can I throw an error that prevents the update on that table?

This question and answers originated from www.stackoverflow.com
Question by (8/1/2008 12:12:19 PM)

Answer

Here is one hack that might work. Isn't clean, but it looks like it might work:

http://www.brokenbuild.com/blog/2006/08/15/mysql-triggers-how-do-you-abort-an-insert-update-or-delete-with-a-trigger/

Essentially you just try to update a column that doesn't exist.

Answer by

Find More Answers
Related Topics  mysql  database  triggers
Related Questions
  • Error in mysql Trigger

    I am trying to create a trigger. First of all I created the table employees and the table employees_audit: CREATE TABLE employees ( employeeNumber int(11) NOT NULL, lastName varchar(50) NOT NUL…
  • error in your SQL syntax creating MySQL trigger

    I try create trigger CREATE TRIGGER `aster_users2` after update ON `aster_users` FOR EACH ROW BEGIN update event set flag=1 where id=1; END; but got next error ERROR 1064 (42000): You h…
  • MySQL Error when trigger calls a procedure

    I have a table (ft_ttd) and want to sort it descending (num) and insert rating numbers into rating column. Something like that: I've created a procedure. CREATE PROCEDURE proc_ft_tt…
  • MySQL Trigger ERROR in phpAdmin

    Hi Is there any error in this TRIGGER Statement.When ever i try to run this in phpAdmin its giving error saying "#1064 - You have an error in your SQL syntax; check the manual that corresponds to yo…
  • error "1064" in trigger creation in mysql?

    while creating trigger in mysql i m getting error 1046. my query is: CREATE TABLE test.Employee( id int, first_name VARCHAR(30), last_name VARCHAR(15), start…
  • can i launch a trigger on select statement in mysql?

    I am trying to run a insert statement on table X each time i select any record from table Y is there anyway that i can accomplish that using MYSQL only? something like triggers? Thank you,
  • mysql trigger to oracle trigger

    I wrote a trigger in mysql that checks to see if a person is able to check out another library item. The checkout limit I have set is 3. I need to convert this to an Oracle trigger but am having lot…
  • Trigger in MySQL

    Please help me for few question in SQL.. I want to create the trigger which prevents insertion in the reservation table of flights ( numflights ), which does not exist. Tables ----------------…
  • MySQL trigger results in error #1064

    I tried writing this small trigger in MySQL, CREATE TRIGGER `leg` BEFORE INSERT ON `bckoff` FOR EACH ROW BEGIN INSERT INTO `bckoff` SET `step`=1; END; after which I get this error.. I'm a n…
  • How to throw an error in MySql procedure?

    What is the mechanism to force the MySQL to throw an error within the stored procedure? I have a procedure which call s another function: PREPARE my_cmd FROM @jobcommand; EXECUTE my_cmd; DEALL…