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

19 lines
626 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`solunionCAP_afterUpdate`
AFTER UPDATE ON `solunionCAP`
FOR EACH ROW
BEGIN
IF NEW.dateLeaving IS NOT NULL THEN
UPDATE client c
2024-04-24 08:57:35 +00:00
JOIN creditClassification cc ON cc.client = c.id
JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id
SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance;
ELSE
UPDATE client c
2024-04-24 08:57:35 +00:00
JOIN creditClassification cc ON cc.client = c.id
JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id
SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance;
END IF;
END$$
DELIMITER ;