Reputation: 100
I saw that have many similar questions here in stackoverflow but no one answer my question.
Where is the problem ?
CREATE OR REPLACE
PROCEDURE "PR_TESTE"( sl_cursor OUT SYS_REFCURSOR)
IS
stm varchar(30000);
BEGIN
stm := 'SELECT * from tb_device_type';
OPEN sl_cursor FOR stm ;
END;
Upvotes: 3
Views: 18349
Reputation: 383
There is no problem in your code. The problem could be in the function/proc calling this procedure. Make sure that the cursor is defined there. I replaced your table tb_device_type to tab. This snippet works fine.
CREATE OR REPLACE
PROCEDURE "PR_TESTE"( sl_cursor OUT SYS_REFCURSOR)
IS
stm varchar(30000);
BEGIN
stm := 'SELECT * from tab';
OPEN sl_cursor FOR stm ;
END;
-----
declare
l_cur sys_refcursor;
l_tname tab.tname%type;
l_tabtype tab.tabtype%type;
l_clusterid tab.clusterid%type;
begin
pr_teste(l_cur);
loop
fetch l_cur into l_tname, l_tabtype, l_clusterid;
exit when l_cur%notfound;
dbms_output.put_line(l_tname);
end loop;
end;
Upvotes: 5