CREATE OR REPLACE PROCEDURE proc_xzh_demo(
p_rownum IN NUMBER,
p_cursor OUT SYS_REFCURSOR
)
AS
BEGIN
OPEN p_cursor FOR SELECT *FROM emp WHERE ROWNUM<p_rownum;
END proc_xzh_demo;
/
这里没有问题
然后定义块结构执行该过程:
DECLARE
v_cursor SYS_REFCURSOR;
v_rownum NUMBER:=5;
v_record emp%ROWTYPE;
BEGIN
CALL proc_xzh_demo(v_rownum,:v_cursor);
LOOP
FETCH v_cursor INTO v_record;
EXIT WHEN v_cursor%NOTFOUND;
END LOOP;
CLOSE v_cursor;
END;
/