salix/db/routines/vn/triggers/creditClassification_before...

15 lines
425 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` 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 = NULL WHERE c.id = NEW.client;
END IF;
END$$
DELIMITER ;