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

19 lines
354 B
SQL

DELIMITER $$
$$
CREATE TRIGGER `vn`.`dms_beforeDelete`
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 ;