trigger examples mysql
Example 1: trigger in mysql syntax
CREATE TRIGGER trigger_name
{BEFORE | AFTER} {INSERT | UPDATE| DELETE }
ON table_name FOR EACH ROW
trigger_body;
Example 2: trigger stock phpmyadmin output message
DELIMITER $$
CREATE TRIGGER testa_trig
BEFORE INSERT ON testa
FOR EACH ROW BEGIN
IF (NEW.c > 100) THEN
SIGNAL SQLSTATE '02000' SET MESSAGE_TEXT = 'Warning: c > 100!';
END IF;
END$$
DELIMITER ;