salix/db/routines/bs/triggers/clientNewBorn_beforeUpdate.sql

12 lines
316 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `bs`.`clientNewBorn_beforeUpdate`
BEFORE UPDATE ON `clientNewBorn`
FOR EACH ROW
BEGIN
-- Si ha pasado un año o mas
IF TIMESTAMPDIFF(YEAR,NEW.lastShipped, OLD.lastShipped) THEN
SET NEW.firstShipped = NEW.lastShipped;
END IF;
END$$
DELIMITER ;