Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Display records using Sys_Refcursor

user1676630Mar 18 2013 — edited Mar 18 2013
Hi All,

I have a function returns results set i.e. sys_refcursor

CREATE OR REPLACE
FUNCTION fn_emp RETURN SYS_REFCURSOR
AS
lc_Cursor SYS_REFCURSOR;
BEGIN
OPEN lc_Cursor FOR
SELECT empno,
ename,
sal,
deptno
FROM emp;

RETURN lc_Cursor;

END fn_emp;

Here is procedure wants to display records using sys_refcursor(Through procedure only)

CREATE OR REPLACE
PROCEDURE test831
AS

lc_cur SYS_REFCURSOR;

BEGIN
lc_cur := fn_emp ;

FOR i IN lc_cur
LOOP

DBMS_OUTPUT.PUT_LINE('i.empno');
DBMS_OUTPUT.PUT_LINE('i.ename');

END LOOP;

END test831;


but the procedure is not compiled.

Can you please check and solve the this requirement.

Advance thanks .
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 15 2013
Added on Mar 18 2013
4 comments
791 views