I would like to create a trigger that tests a condition before insertion and if the condition is met then cancels the insert.
I came across this code in the manual which contains if statement, but no ways to cancel the insert is specified in the documentation.
CREATE TRIGGER upd_check BEFORE UPDATE ON account
-> FOR EACH ROW
-> BEGIN
-> IF NEW.amount < 0 THEN
-> SET NEW.amount = 0;
-> ELSEIF NEW.amount > 100 THEN
-> SET NEW.amount = 100;
-> END IF;
-> END;