Scope of PL/SQL Exceptions
DECLARE
past_due EXCEPTION;
acct_num NUMBER;
BEGIN
DECLARE ---------- sub-block begins
past_due EXCEPTION; -- this declaration prevails
acct_num NUMBER;
due_date DATE := SYSDATE
- 1;
todays_date DATE := SYSDATE;
BEGIN
IF due_date < todays_date THEN
RAISE past_due; -- this is not handled
END IF;
END; ------------- sub-block ends
EXCEPTION
WHEN past_due THEN -- does not handle raised exception
dbms_output.Put_line('Handling PAST_DUE exception.');
WHEN OTHERS THEN
dbms_output.Put_line('Could not recognize PAST_DUE_EXCEPTION in this scope.');
END;
/
OUTPUT:-
Could not recognize PAST_DUE_EXCEPTION in this scope.
PL/SQL procedure successfully completed.
0 comments:
Post a Comment