MySQL Trigger to prevent INSERT under certain conditions

Posted by Richard Mar. on Stack Overflow See other posts from Stack Overflow or by Richard Mar.
Published on 2010-06-05T20:18:27Z Indexed on 2010/06/05 20:22 UTC
Read the original article Hit count: 97

Filed under:
|

I want to make a trigger that will prevent the insertion if the birthdate (one of the columns) is in the future. I have this:

CREATE TRIGGER foo
BEFORE INSERT ON table
FOR EACH ROW
BEGIN
  IF NEW.birthdate > CURRENT_DATE()
  THEN
    ???mystery???
  END IF;
END;

What goes in the mystery part?

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql