解决方案 »

  1.   


    给个demo返回游标的存储过程
    create or replace procedure p_test_1(cur out sys_refcursor)
    as
    begin
      open cur for select empno,ename from scott.emp;
    end;
    /统计行数
    declare
    type tp1 is record(c1 number(4),c2 varchar2(10));
    type tp2 is table of tp1 index by binary_integer;
    tp_inst tp2;
    v_cur sys_refcursor;
    begin
      p_test_1(v_cur);
      --将游标中的记录取到数组中
      fetch v_cur bulk collect into tp_inst;
      --取完以后,查看游标取到第几行,就知道记录数了
      dbms_output.put_line(v_cur%rowcount);
      --或者,可以通过统计数组中的元素个数来得出
      dbms_output.put_line(tp_inst.count);
      close v_cur;
    end;