Forum Discussion
skareemulla
8 years agoNew Contributor
Hi,
I got the solution for it, now I can able read the response which is returned by calling PL/SQL stored procedure or function using below code
Prerequisite:
Add JDBC driver in Lib folder of Ready API workspace.
Calling Procedure which is having out parameter as REF CURSOR
Import oracle.jdbc.*; ... CallableStatement cstmt; ResultSet cursor; // Use a PL/SQL block to open the cursor cstmt = conn.prepareCall ("{call PackageName.Procedurename(InputPar1,?)"); // '?' is for out parameter cstmt.registerOutParameter(1, OracleTypes.CURSOR); cstmt.execute(); cursor = ((OracleCallableStatement)cstmt).getCursor(1); // Use the cursor like a normal ResultSet while (cursor.next ()) {System.out.println (cursor.getString(1));}
Calling PL/SQL function which return REF CURSOR in response:
Import oracle.jdbc.*; ... CallableStatement cstmt; ResultSet cursor; // Use a PL/SQL block to open the cursor cstmt = conn.prepareCall ("{ ? = call Packagename.Funcitonname(Par1,Par2)}"); cstmt.registerOutParameter(1, OracleTypes.CURSOR); cstmt.execute(); cursor = ((OracleCallableStatement)cstmt).getCursor(1); // Use the cursor like a normal ResultSet while (cursor.next ()) {System.out.println (cursor.getString(1));}
Regards
Kareem
Related Content
- 2 months agoNicolaFilosa_SE