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

17 lines
435 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`province_afterUpdate`
AFTER UPDATE ON `province`
FOR EACH ROW
BEGIN
IF !(OLD.autonomyFk <=> NEW.autonomyFk) THEN
CALL zoneGeo_setParent(NEW.geoFk,
(SELECT geoFk FROM autonomy WHERE id = NEW.autonomyFk));
END IF;
IF !(OLD.`name` <=> NEW.`name`) THEN
UPDATE zoneGeo SET `name` = NEW.`name`
WHERE id = NEW.geoFk;
END IF;
END$$
DELIMITER ;