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

15 lines
427 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`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 ;