What is the output in your session?

Examine this package:
CREATE OR REPLACE PACKAGE pack_cur
IS
CURSOR c1 IS
SELECT prodid
FROM poduct
ORDER BY prodid DESC;
PROCEDURE proc1;
PROCEDURE proc2;
END pack_cur;
/
CREATE OR REPLACE PACKAGE BODY pack_cur
IS
v_prodid NUMBER;
PROCEDURE proc1 IS
BEGIN
OPEN C1
LOOP
FETCH C1 INTO v_prodid;
DBMS_OUTPUT.PUT_LINE ( ‘Row is: ‘| | c1%ROWCOUNT); EXIT WHEN c1%ROWCONT >= 3;
END LOOP;
END procl;
PROCEDURE proc2 IS
BEGIN
LOOP
FETCH C1 INTO v_prodid;
DBMS_OUTPUT.PUT_LINE ( ‘Row is: ‘| | c1%ROWCOUNT); EXIT WHEN c1%ROWCONT >= 6;
END LOOP;
CLOSE C1;
END proc2;
END pack_cur;
/
The product table has more than 1000 rows. The SQL *Plus SERVEROUTPUT setting is turned on in your session.
You execute the procedure PROC1 from SQL *Plus with the command:
EXECUTE pack_cur.proc1
What is the output in your session?

Examine this package:
CREATE OR REPLACE PACKAGE pack_cur
IS
CURSOR c1 IS
SELECT prodid
FROM poduct
ORDER BY prodid DESC;
PROCEDURE proc1;
PROCEDURE proc2;
END pack_cur;
/
CREATE OR REPLACE PACKAGE BODY pack_cur
IS
v_prodid NUMBER;
PROCEDURE proc1 IS
BEGIN
OPEN C1
LOOP
FETCH C1 INTO v_prodid;
DBMS_OUTPUT.PUT_LINE ( ‘Row is: ‘| | c1%ROWCOUNT); EXIT WHEN c1%ROWCONT >= 3;
END LOOP;
END procl;
PROCEDURE proc2 IS
BEGIN
LOOP
FETCH C1 INTO v_prodid;
DBMS_OUTPUT.PUT_LINE ( ‘Row is: ‘| | c1%ROWCOUNT); EXIT WHEN c1%ROWCONT >= 6;
END LOOP;
CLOSE C1;
END proc2;
END pack_cur;
/
The product table has more than 1000 rows. The SQL *Plus SERVEROUTPUT setting is turned on in your session.
You execute the procedure PROC1 from SQL *Plus with the command:
EXECUTE pack_cur.proc1
What is the output in your session?

A.
ERROR at line 1:

B.
Row is:
Row is:
Row is:

C.
Row is: 1
Row is: 2
Row is: 3

D.
Row is: 4
Row is: 5
Row is: 6

Explanation:
proc1 will open the C1 Cursor and go into a Loop. The Loop Fetches and outputs the first three records. Since the SET SERVEROUTPUT Command was set the results will be displayed
Incorrect Answers

A: This procedure will successfully execute with errors. B: The output will include the Row Number fetched from the cursor. D: This would be the output if you executed the proc1 cursor fro the second time.



Leave a Reply 0

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