CREATE TRIGGER business_rules
BEFORE INSERT ON empprojact
REFERENCING NEW AS n
FOR EACH ROW
BEGIN ATOMIC
-- Business Rule One (Project ending date Can't be NULL)
IF (n.emendate IS NULL) THEN
SET n.emendate = CURRENT date;
END IF;
-- Business Rule Two (Project ending date Can't end in last month of the year)
IF (n.emendate BETWEEN '2009-12-01' AND '2009-12-31') THEN
SIGNAL SQLSTATE '90000'
SET MESSAGE_TEXT = 'Business Rule violation - 90000';
END IF;
END!
如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!
赞0
添加新评论0 条评论