17 lines
390 B
SQL
17 lines
390 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` 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 ;
|