Rahul's Argument !! Function/Procedure retrun Cursor itself to a Java Program?!!
nabhilash
Greenhorn
Joined: May 10, 2001
Posts: 8
posted
0
Dear Friends In fact this code discusssion really created curiosity. pisal rahul advises that u can fetch cursor to java program. as follows. I would like to know then how to write a procedure for that. I want fetch 3 feilds from a citymaster table and return to java Program . Can anyone help out. Rahul r u there somewhere near by Rahul Argues as follows : do the following CallableStatement stmt = con.prepareCall ("{? = call procedurename(?)}"); stmt.registerOutParameter(1,OracleTypes.CURSOR); stmt.setString(2,"Rahul"); stmt.executeUpdate(); ResultSet rs = (ResultSet)stmt.getObject(1);
Frank Carver
Sheriff
Joined: Jan 07, 1999
Posts: 6913
posted
0
"nabhilash", The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements. Thanks.
Please see following example which I borrow now from one of my previous assignments: import java.sql.*; import java.io.*; import oracle.jdbc.driver.*; public class retrefcur_samp { public static void main (String args []) // throws SQLException { try { DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); connection URL. Connection conn = DriverManager.getConnection ("jdbcracle:thin:@pavilion03:1529ra8i", "you", "me"); init (conn); CallableStatement call = conn.prepareCall ("{ ? = call java_refcursor.job_listing (?)}");
Dear Andre, Thanks a lot for that advice. It is of really great help Regards Abhilash
mukesh kumar
Greenhorn
Joined: Aug 30, 2001
Posts: 1
posted
0
I saw Topic: Rahul's Argument !! Function/Procedure retrun Cursor itself to a Java Program?!! I have similar problem. I am selecting 7 fields from 3 tables and creating a cursor in a function. It returns all rows in one step. I want only 10 rows at a time (As in this topic getting all row at a time). For this I have to fetch in loop for 10 times, but gives compilation error in oracle when I write fetch into ref_cursor. Should I take all values in arrays or is there a way to modify andre van winssen's suggested way.