创建了一个存储过程usp_getset,查看了一下user_procedures表,已经创建成功:create or replace procedure usp_getset
(
  acs_results out sys_refcursor
)
as
begin
  open acs_results for
    select * from employees;
end usp_getset;
但是在调用的时候报错,调用代码如下:declare
   cs_results sys_refcursor;
begin
  usp_getset(cs_results);
  for test in cs_results loop
    dbms_output.put_line(test.employee_id);
  end loop;
end;
系统提示:
ORA-06550: line 5, column 15:
PLS-00221: 'CS_RESULTS' is not a procedure or is undefined
ORA-06550: line 5, column 3:
PL/SQL: Statement ignored麻烦大家看看是怎么回事呀,我接触oracle不久,谢谢

解决方案 »

  1.   


    declare
       cs_results sys_refcursor;
       r_employees employees%rowtype;
    begin
      usp_getset(cs_results);
      loop
      fetch cs_results into r_employees;
        exit when cs_results%not_found;
        dbms_output.put_line(r_employees.employee_id);
      end loop;
    end;
      

  2.   

    ref cursor 不能用for循环,只能使用普通loop实现
    DECLARE
       cs_results      sys_refcursor;
       employees_row   employees%ROWTYPE;
    BEGIN
       usp_getset (cs_results);   LOOP
          FETCH cs_results
           INTO employees_row;      EXIT WHEN cs_results%NOTFOUND;
          DBMS_OUTPUT.put_line (employees_row.employee_id);
       END LOOP;
    close cs_results;
    END;
      

  3.   

    大奔哥手好快,捉虫来了exit when cs_results%notfound;