问题
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