15 lines
316 B
MySQL
15 lines
316 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`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 ;
|