DROP TRIGGER IF EXISTS `vn`.`receipt_afterInsert`; DELIMITER $$ CREATE DEFINER=`root`@`%` TRIGGER `vn`.`receipt_afterInsert` AFTER INSERT ON `receipt` FOR EACH ROW CALL clientRisk_update(NEW.clientFk, NEW.companyFk, -NEW.amountPaid)$$ DELIMITER ; DROP TRIGGER IF EXISTS `vn`.`receipt_beforeUpdate`; DELIMITER $$ CREATE DEFINER=`root`@`%` TRIGGER `vn`.`receipt_beforeUpdate` BEFORE UPDATE ON `receipt` FOR EACH ROW BEGIN CALL clientRisk_update(OLD.clientFk, OLD.companyFk, OLD.amountPaid); CALL clientRisk_update(NEW.clientFk, NEW.companyFk, -NEW.amountPaid); END$$ DELIMITER ; DROP TRIGGER IF EXISTS `vn`.`receipt_beforeDelete`; DELIMITER $$ CREATE DEFINER=`root`@`%` TRIGGER `vn`.`receipt_beforeDelete` BEFORE DELETE ON `receipt` FOR EACH ROW CALL clientRisk_update(OLD.clientFk, OLD.companyFk, OLD.amountPaid)$$ DELIMITER ;