How to display sys_refcursor output pl sql with Toad tool

為{幸葍}努か 提交于 2019-12-24 11:29:46

问题


I have written a query to execute the SP. The execution works fine with this. However, I'm not able to see output results.

declare v_rc    sys_refcursor;

begin
   SUSER.TRANS_REP (v_rc  ,'Investments Series','31-12-2012','Dealer Group','All Adv') ;

 end;

How to display output result with sys_refcursor. Please help.

note: I tried to print cursor but did not get any help. Also refered this (How to display a sys_refcursor data in TOAD's DataGrid and https://community.oracle.com/thread/627571), but still no help.


回答1:


In SQL*Plus you could easily do it using a refcursor variable.

SQL> var r refcursor
SQL>
SQL> BEGIN
  2    OPEN :r FOR SELECT empno,ename FROM emp;
  3  END;
  4  /

PL/SQL procedure successfully completed.

SQL> print r

     EMPNO ENAME
---------- ----------
      7369 SMITH
      7499 ALLEN
      7521 WARD
      7566 JONES
      7654 MARTIN
      7698 BLAKE
      7782 CLARK
      7788 SCOTT
      7839 KING
      7844 TURNER
      7876 ADAMS

     EMPNO ENAME
---------- ----------
      7900 JAMES
      7902 FORD
      7934 MILLER

14 rows selected.

SQL>

I guess in TOAD, you have some sort of output options. Select the variables you want to see the values in the output, the ref cursor result set would open in a different window.



来源:https://stackoverflow.com/questions/28297520/how-to-display-sys-refcursor-output-pl-sql-with-toad-tool

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!