View the Exhibit to examine the PL/SQL code.
Which statement is true about the execution of the code?
A.
The exception raised in the code is handled by the exception handler for the PAST_DUE exception.
B.
It does not execute because you cannot declare an exception with a similar name in the subblock.
C.
The PAST_DUE exception raised in the subblock causes the program to terminate abruptly because there is no exception handler in the subblock.
D.
The PAST_DUE exception raised by the enclosing block is not propagated to the outer block and it is handled by the WHEN OTHERS exception handler
answer is C
D is the right answer
D is the right answer. Check http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/errors.htm#BCFEHAHI
thanks William .it really helped.
Thanks
yes D is the right ans.
D is the correct answer because if we declare the global exception again in the some inner blocks then the local declarAtion of the exception prevails.
C is the correct answer, because when others exception is not defined in the inner block.
Also refer to this URL again http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/errors.htm#BCFEHAHI
D
Right answer is C.
Here is explanations from oracle documetation:
The enclosing block does not handle the raised exception because the declaration of past_due in the sub-block prevails. Though they share the same name, the two past_due exceptions are different, just as the two acct_num variables share the same name but are different variables. Thus, the RAISE statement and the WHEN clause refer to different exceptions. To have the enclosing block handle the raised exception, you must remove its declaration from the sub-block or define an OTHERS handler.
link to the doc:
http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/errors.htm#i1863
Test:
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
— Does not handle raised exception
WHEN past_due THEN
DBMS_OUTPUT.PUT_LINE
('Handling PAST_DUE exception.');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE
('Could not recognize PAST_DUE_EXCEPTION in this scope.');
raise;
END;
Error at line 1
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at line 23
HY VLADIMIR
be careful
it’s all right but,
if enclosed block don’t find exception named handle, plsql try to find it in enclosign block and in enclosing block there is a when other handle exception….
D
@piero. You are right
DECLARE
past_due EXCEPTION;
acct_num NUMBER;
BEGIN
DECLARE
past_due EXCEPTION;
acct_num NUMBER;
due_date DATE := sysdate -1;
todays_date DATE :=sysdate;
BEGIN
IF due_date < todays_date THEN
RAISE past_due;
END IF;
END;
EXCEPTION
WHEN past_due THEN
dbms_output.put_line ('Handling PAST_DUE exception.');
WHEN OTHERS THEN
dbms_output.put_line ('Could not recognize exception.');
END;
/
D is correct answer
The exception is overrided in inner block
That is the best search engine in the planet
http://google.com
Excellent blog post . I absolutely love this site . Keep it up!
http://www.investopedia.com/advisor-network/advisors/61757/wendy-ann-payne-csa-cep-/
This is the awesome wonderful search engine in the planet
http://google.com
Awesomely done post. I absolutely appreciate your site. Keep it up!
http://firstlime.com/category/health/page/3/