salix/db/routines/vn/triggers/province_beforeUpdate.sql

15 lines
314 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`province_beforeUpdate`
BEFORE UPDATE ON `province`
FOR EACH ROW
BEGIN
IF !(OLD.autonomyFk <=> NEW.autonomyFk) THEN
SET NEW.countryFk = (SELECT a.countryFk FROM vn.autonomy a WHERE a.id = NEW.autonomyFk);
END IF;
END$$
DELIMITER ;