MySql_Trigger.sql 934 Bytes
/**
 * @filesource MySql_Trigger.sql
 *
 * @category freeSN
 * @copyright Copyright by mensch.coop e.G. 2009
 * @mailto	dev [at] mensch.coop
 * @version 0.4.200901
 * @link http://mensch.coop
 */

DELIMITER |

CREATE TRIGGER Trigg_updateAuthorisationWriteList AFTER DELETE ON losp_BasisElement_writeauthorisation
	FOR EACH ROW BEGIN

	DECLARE var_DeleteListID INT;
-- 	SET var_DeleteListID=;
	SET var_DeleteListID=(select case when ((SELECT 1  FROM losp_BasisElement_writeauthorisation WHERE ListID=OLD.ListID LIMIT 1)=1) THEN 1 else 0 end);
	IF  (var_DeleteListID=0) THEN
-- 	IF ((SELECT ProfileID  FROM losp_BasisElement_writeauthorisation WHERE ProfileID=OLD.ProfileID LIMIT 1)>0) THEN
		UPDATE losp_BasisElement SET AuthWriteListID=0 WHERE losp_BasisElement.AuthWriteListID=OLD.ListID;
-- 	ELSE
-- 		UPDATE losp_BasisElement SET AuthWriteListID=7 WHERE losp_BasisElement.AuthWriteListID=OLD.ListID;
	END IF;
  END;

|

DELIMITER ;