Which statement is true about the execution of the code if the query in the PL/SQL block returns no rows?

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?

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.



Leave a Reply 12

Your email address will not be published. Required fields are marked *


Reju

Reju

Program executes successfully
and gives output. Please tell if wrong.

Igor

Igor

if the query in the PL/SQL block returns no rows? = NO_DATA_FOUND = EXCEPTION = Answer is A

Edmilson

Edmilson

if in table employees there is a record with first_name = ‘John’ and last_name = null then the program executes successfully and the output is No ROWS_FOUND.

:)

:)

I would make one slight adjustment to your comment:

if in table employees there is ONE record with first_name = ‘John’ and last_name = null then the program executes successfully and the output is No ROWS_FOUND.

But since there is a possibility that there are more than 1 … => correct answer A

SP

SP

In the question, mentioned that ‘if the query in the PL/SQL block returns no rows?’

So A is correct.

Heena

Heena

in the question its mentioned that the query returns no rows.. so there should have been an exception handler with no_data_found for the program to execute successfully.

In current scenario A is correct.

ali

ali

A is correct, because have 3 last_names have same first_name(John)
from that will be abruptly terminates , see:

SQL> declare
2 name varchar2(25);
3 begin
4 select last_name into name from employees where first_name=’John’;
5 if name is null
6 then
7 dbms_output.put_line(‘no data found’);
8 else
9 dbms_output.put_line(‘last_name:’|| name);
10 end if;
11 end;
12 /

ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at line 4

Ahmed

Ahmed

A is correct

Chrys

Chrys

If there is just one John it will Show John’s Lastname, if there are more Johns it will raise a error that the Response has more rows and if ther are not Johns it will raise an error