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

14 lines
370 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`province_beforeInsert`
BEFORE INSERT ON `province`
FOR EACH ROW
BEGIN
SET NEW.geoFk = zoneGeo_new('province', NEW.`name`,
(SELECT geoFk FROM autonomy WHERE id = NEW.autonomyFk));
SET NEW.countryFk = (SELECT a.countryFk FROM vn.autonomy a WHERE a.id = NEW.autonomyFk);
END$$
DELIMITER ;