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

12 lines
316 B
MySQL
Raw Normal View History

DELIMITER $$
2024-01-25 16:33:54 +00:00
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 ;