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`.`creditClassification_beforeUpdate`
|
2024-01-15 11:31:03 +00:00
|
|
|
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 = NULL WHERE c.id = NEW.client;
|
|
|
|
END IF;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|