salix/db/changes/10460-mother/02-dmsTrigger.sql

19 lines
354 B
MySQL
Raw Normal View History

2022-05-03 09:16:56 +00:00
DELIMITER $$
$$
2022-05-16 09:34:29 +00:00
CREATE TRIGGER `vn`.`dms_beforeDelete`
2022-05-03 09:16:56 +00:00
BEFORE DELETE
ON dms FOR EACH ROW
BEGIN
DECLARE vCanNotBeDeleted INT;
SELECT COUNT(*) INTO vCanNotBeDeleted
FROM dmsType dt
WHERE NOT (code <=> 'trash')
AND dt.id = OLD.dmsTypeFk;
IF vCanNotBeDeleted THEN
CALL util.throw('A dms can not be deleted');
END IF;
END$$
DELIMITER ;