-- Collection of code snippets by Arne Vajhøj 
-- posted to eksperten.dk, usenet and other places (2002-now) 
CREATE TABLE trigtest (i INTEGER NOT NULL PRIMARY KEY);
DELIMITER |
CREATE TRIGGER trigtest_insert BEFORE INSERT ON trigtest
  FOR EACH ROW BEGIN
    IF NEW.i > 10 THEN
      CALL OOOPS(); -- should be RETURN FALSE; or RAISEERROR; but MySQL 5.0 does not support that
    END IF;
  END;
|
DELIMITER ;
INSERT INTO trigtest VALUES (1);
INSERT INTO trigtest VALUES (10);
INSERT INTO trigtest VALUES (100);
DROP TRIGGER trigtest_insert;
DROP TABLE trigtest;
