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