I am guessing that you want to validate the data and report an error when the data doesn't look right. In the more recent versions of MySQL, you can use [signal][1]
:
DELIMITER $$
CREATE TRIGGER `Movie_BINS` BEFORE INSERT ON `movies` FOR EACH ROW
BEGIN
IF ((new.length < 30 OR new.length > 480) AND new.year < 1929) THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Data error on insert';
END IF;
END$$
DELIMITER ;
A before insert
trigger doesn't need to do an explicit insert into the table (in fact, it can't). Instead, if it completes successfully, then the data in the new
record will be inserted. If you want to stop the insert, you need to generate an error, and signal
is a good way to do that.