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

15 lines
320 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn-admin`@`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 ;