19 lines
661 B
SQL
19 lines
661 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`solunionCAP_AFTER_UPDATE`
|
|
AFTER UPDATE ON `solunionCAP`
|
|
FOR EACH ROW
|
|
BEGIN
|
|
IF NEW.dateLeaving IS NOT NULL THEN
|
|
UPDATE vn2008.Clientes c
|
|
JOIN creditClassification cc ON c.Id_Cliente = cc.client
|
|
JOIN creditInsurance ci ON ci.creditClassification = cc.id
|
|
SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance;
|
|
ELSE
|
|
UPDATE vn2008.Clientes c
|
|
JOIN creditClassification cc ON c.Id_Cliente = cc.client
|
|
JOIN creditInsurance ci ON ci.creditClassification = cc.id
|
|
SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance;
|
|
END IF;
|
|
END$$
|
|
DELIMITER ;
|