salix/db/changes/10110-postCampaign/00-creditClassificationBefo...

17 lines
474 B
MySQL
Raw Normal View History

DELIMITER $$
DROP TRIGGER IF EXISTS `vn`.`creditClassification_BEFORE_UPDATE` $$
CREATE DEFINER=`root`@`%` TRIGGER `vn`.`creditClassification_beforeUpdate` BEFORE UPDATE ON `creditClassification` FOR EACH ROW
BEGIN
IF NEW.client <> OLD.client THEN
CALL util.throw('NOT_ALLOWED_CHANGE_CLIENT');
END IF;
IF NEW.dateEnd IS NOT NULL AND OLD.dateEnd IS NULL THEN
UPDATE `client` c
SET creditInsurance = 0 WHERE c.id = NEW.client;
END IF;
END$$
DELIMITER ;