Which statement is true about the fetch statements in the PL/SQL code?

Examine the following PL/SQL code:

Which statement is true about the fetch statements in the PL/SQL code?

Examine the following PL/SQL code:

Which statement is true about the fetch statements in the PL/SQL code?

A.
Each fetch retrieves the first row and assigns values to the target variables.

B.
Each fetch retrieves the next consecutive row and assigns values to the target variables.

C.
They produce an error because you must close and reopen the cursor before each fetch –
statement.

D.
Only the first fetch retrieves the first row and assigns values to the target variables- the second
produces an error.



Leave a Reply 6

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


Alisa

Alisa

DECLARE
CURSOR c1
IS SELECT Last_Name
FROM Employee
ORDER BY Last_Name;
name1 employee.Last_Name%TYPE;
name2 employee.Last_Name%TYPE;
name3 employee.Last_Name%TYPE;
name4 employee.Last_Name%TYPE;
name5 employee.Last_Name%TYPE;
BEGIN
OPEN c1;
FETCH c1 INTO name1;
FETCH c1 INTO name2;
FETCH c1 INTO name3;
FETCH c1 INTO name4;
FETCH c1 INTO name5;
CLOSE c1;
DBMS_OUTPUT.put_line(name1);
DBMS_OUTPUT.put_line(name2);
DBMS_OUTPUT.put_line(name3);
DBMS_OUTPUT.put_line(name4);
DBMS_OUTPUT.put_line(name5);
END;

Output:
Black
Cat
Martin
Mathews
Rice