Examine the following PL/SQL code:
Which statement is true about the execution of the PL/SQL code?
A. It executes successfully.
B. It generates a run-time exception.
C. It does not execute because of syntax error
D. It executes successfully and generates a warning.
Divide by Zero exception is not handled.
Answer: B
Following exception is generated:
HR@XE > DECLARE
2 stock_price number:=9.73;
3 net_earnings number:=0;
4 pe_ratio number;
5 BEGIN
6 pe_ratio:=stock_price/net_earnings;
7 dbms_output.put_line(‘Price/earnings ratio = ‘ || pe_ratio);
8 end;
9 /
DECLARE
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at line 6