Using RAISE to Force a User-Defined Exception
DECLARE
out_of_stock EXCEPTION;
number_on_hand NUMBER := 0;
BEGIN
IF number_on_hand < 1 THEN
RAISE out_of_stock; -- raise an exception that we defined
END IF;
EXCEPTION
WHEN out_of_stock THEN
-- handle the error
dbms_output.Put_line('Encountered out-of-stock error.');
END;
/
OUTPUT:-
Encountered out-of-stock error.
PL/SQL procedure successfully completed.
0 comments:
Post a Comment