Examine the following PL/SQL code:
Which statement is true about the execution of the code if the query in the PL/SQL block returns no rows?
A.
The program abruptly terminates and an exception is raised.
B.
The program executes successfully and the output is No ROWS_FOUND.
C.
The program executes successfully and the query fetches a null value in the V_LNAME
variable.
D.
Program executes successfully, fetches a NULL value in the V_LNAME variable and an
exception is raised.
Explanation:
ans is A
below error is encountered;
ORA-01403: no data found
ORA-06512: at line 4
01403. 00000 – “no data found”
A
A
but for too rows ORA-01422
SELeCT LAST_NAME FROM EMPLOYEES WHERE FIRST_NAME = ‘John’;
LAST_NAME
Chen
Russell
Seo
declare
v_lname varchar2(15);
begin
SELeCT LAST_NAME into v_lname FROM EMPLOYEES WHERE FIRST_NAME = ‘John’;
if v_lname is null then
dbms_output.put_line(‘n u l l ‘);
else
dbms_output.put_line(v_lname);
end if;
end;
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 5
A
A. Error ORA-01403