TOAD displaying cursor recordset returned by stored procedure

徘徊边缘 提交于 2019-12-02 09:59:18

To return the return_flag, which is int=1 or 0 you need function that returns a single value, not recordset. Below are general recordset examples - hope this helps:

DECLARE
  TYPE empcurtyp IS REF CURSOR;
  emp_cv  empcurtyp;
--
  TYPE namelist IS TABLE OF scott.emp.ename%TYPE;
  TYPE sallist  IS TABLE OF scott.emp.sal%TYPE;
  names   namelist;
  sals    sallist;
BEGIN
  OPEN emp_cv FOR
    SELECT ename, sal FROM scott.emp
      WHERE job = 'MANAGER' ORDER BY sal DESC;
--
  FETCH emp_cv BULK COLLECT INTO names, sals;
  CLOSE emp_cv;

-- loop through the names and sals collections
 FOR i IN names.FIRST .. names.LAST LOOP
   DBMS_OUTPUT.PUT_LINE
     ('Name = ' || names(i) || ', salary = ' || sals(i));
   END LOOP;
END;
/

-- SYS_REFCURSOR example --
DECLARE
  p_rc_type  SYS_REFCURSOR;
  emp_rec    scott.emp%ROWTYPE;
 --
 PROCEDURE p_Emp_Info (p_cur_var OUT SYS_REFCURSOR)
 IS 
 BEGIN
    OPEN p_cur_var FOR 
     SELECT ename, job FROM scott.emp WHERE job = 'MANAGER';
   LOOP
    FETCH p_cur_var INTO emp_rec.ename, emp_rec.job;
    EXIT WHEN p_cur_var%NOTFOUND;
     dbms_output.put_line(emp_rec.ename ||' '|| emp_rec.job);
   END LOOP;
  CLOSE p_cur_var;
 END p_Emp_Info;
 --
 BEGIN
  p_Emp_Info(p_rc_type);
END;
/
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!