How can I setup a function to return a ref cursor that references an existing cursor?
Hi there,
I am trying to create a database function/procedure that returns a ref cursor that will reference an existing cursor. For example,
CREATE or replace PACKAGE MyLib AS
TYPE curTyp IS REF CURSOR;
function GetCursor(curNum INT) return curTyp;
END MyLib;
/
CREATE or replace PACKAGE BODY MyLib AS
cursor c1 is select * from dept;
cursor c2 is select * from emp;
function GetCursor(curNum INT) return curTyp IS
myCur curTyp;
BEGIN
-- This doesn't work, but how can I make it work?
if curNum = 1 then
OPEN myCur FOR c1;
else
OPEN myCur for c2;
end if;
return myCur;
END;