CREATE OR REPLACE PROCEDURE test(PRESULT OUT SYS_REFCURSOR) AS
BEGIN
OPEN PRESULT FOR
SELECT level as lv FROM dual connect by level < 100;
END;
declare
v_PRESULT SYS_REFCURSOR;
CURSOR TMPCURSOR IS
SELECT 1 as lv from dual WHERE ROWNUM = 1;
R TMPCURSOR%ROWTYPE;
begin
test(v_PRESULT);
LOOP
FETCH v_PRESULT
INTO R;
EXIT WHEN v_PRESULT%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(R.lv);
END LOOP;
end;
注意TMPCURSOR 的结构必须与存储过程test 返回的游标结构一致,否则就会出现错误
不知道有么有更好的解决办法呢? 把TMPCURSOR 去掉。