我想创建一个简单的触发器来检查表中存储的变量。
如果变量的值为'1',则批准插入,
否则如果变量的值为'2',则提示错误信息。
CREATE OR REPLACE TRIGGER approval
BEFORE INSERT ON VIP
REFERENCING OLD AS MEMBER
FOR EACH ROW
DECLARE
CONDITION_CHECK NUMBER;
BEGIN
SELECT CONDITION INTO CONDITION_CHECK FROM MEMBER;
IF CONDITION_CHECK = '2' THEN
RAISE_APPLICATION_ERROR (-20000, ' UPGRADE DENIED!');
END IF;
END;
但是即使条件值为“1”,此触发器也会禁用所有条目。