Oracle - Trigger to check constraint before insert
Posted
by
user1816507
on Stack Overflow
See other posts from Stack Overflow
or by user1816507
Published on 2012-11-13T16:51:57Z
Indexed on
2012/11/13
17:00 UTC
Read the original article
Hit count: 193
i would like to create a simple trigger to check a stored variable from a table.
if the value of the variable is '1', then approve the insertion
else if the value of the variable is '2', then prompt error message.
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;
But this trigger disable all the entries even when the condition value is '1'.
© Stack Overflow or respective owner