I'm working on converting a stored procedure from SQL server to Oracle. This stored procedure provides a direct resultset. I mean that if you call the stored procedure in eg Management Studio you directly obtain the resultset.
By converting to Oracle I walk against the problem that I in Oracle will not display the resultset
I searched on the Internet and have seen that the stored procedure should yield a REF CURSOR, but I still walk with the problem to write a little piece of code to obtain the resultset en process that.
Pseudo Code:
Call stored procedure and obtain cursor Do something with that cursor so that my resultset appears
Someone an idea?
To return a cursor from an Oracle stored procedure, the output parameter of the procedure must be declared as a cursor type. You must also declare that parameter as a cursor in the LWJDBC adapter. Below is a complete working example utilizing existing pools and a Sterling Integrator table.
A stored procedure does not have a return value but can optionally take input, output, or input-output parameters. A stored procedure can return output through any output or input-output parameter.
To make the migration of other databases to the Oracle Database easier, Oracle Database 12c Release 1 added a new feature called implicit statement result that allows you to return one or more result sets from a stored procedure by using the dbms_sql package.
Stored procedures and functions (subprograms) can be compiled and stored in an Oracle Database XE, ready to be executed. Once compiled, it is a schema object known as a stored procedure or stored function, which can be referenced or called any number of times by multiple applications connected to Oracle Database XE.
In SQL Plus:
SQL> create procedure myproc (prc out sys_refcursor) 2 is 3 begin 4 open prc for select * from emp; 5 end; 6 / Procedure created. SQL> var rc refcursor SQL> execute myproc(:rc) PL/SQL procedure successfully completed. SQL> print rc EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- ----------- ---------- ---------- ---------- 7839 KING PRESIDENT 17-NOV-1981 4999 10 7698 BLAKE MANAGER 7839 01-MAY-1981 2849 30 7782 CLARKE MANAGER 7839 09-JUN-1981 2449 10 7566 JONES MANAGER 7839 02-APR-1981 2974 20 7788 SCOTT ANALYST 7566 09-DEC-1982 2999 20 7902 FORD ANALYST 7566 03-DEC-1981 2999 20 7369 SMITHY CLERK 7902 17-DEC-1980 9988 11 20 7499 ALLEN SALESMAN 7698 20-FEB-1981 1599 3009 30 7521 WARDS SALESMAN 7698 22-FEB-1981 1249 551 30 7654 MARTIN SALESMAN 7698 28-SEP-1981 1249 1400 30 7844 TURNER SALESMAN 7698 08-SEP-1981 1499 0 30 7876 ADAMS CLERK 7788 12-JAN-1983 1099 20 7900 JAMES CLERK 7698 03-DEC-1981 949 30 7934 MILLER CLERK 7782 23-JAN-1982 1299 10 6668 Umberto CLERK 7566 11-JUN-2009 19999 0 10 9567 ALLBRIGHT ANALYST 7788 02-JUN-2009 76999 24 10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With