Using RAISE to Force a Pre-Defined Exception
DECLARE
acct_type INTEGER := 7;
BEGIN
IF acct_type NOT IN (1,2,3) THEN
RAISE invalid_number; -- raise predefined exception
END IF;
EXCEPTION
WHEN invalid_number THEN
dbms_output.Put_line('HANDLING INVALID INPUT BY ROLLING BACK.');
ROLLBACK;
END;
/
OUTPUT:-
HANDLING INVALID INPUT BY ROLLING BACK.
PL/SQL procedure successfully completed.
0 comments:
Post a Comment