This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Calling Oracle Stored Procedure which has parameter as CURSOR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Calling Oracle Stored Procedure which has parameter as CURSOR" Watch "Calling Oracle Stored Procedure which has parameter as CURSOR" New topic
Author

Calling Oracle Stored Procedure which has parameter as CURSOR

anandaraj krishnan
Greenhorn

Joined: Sep 13, 2001
Posts: 1
Hi,
I would like to know,how to get more than 1 record from oracle db(by calling stored procedure) in Java.What I did is I created a Stored Procedure in oracle as :
CREATE OR REPLACE PROCEDURE getControlData(seqNum OUT seqPack.seqCur) AS
BEGIN
OPEN seqNum FOR SELECT SEQ_NO FROM CONTROL_M;
END;

CREATE OR REPLACE PACKAGE seqPack AS
TYPE seqCur IS REF CURSOR;
END seqPack;
So if I want to call this Stored Procedure from simple Java class file using JDBC,wat I need to do.I know very well that I've to use callableStatement in Java.Sql.*. But I don't know how to call a stored procedure which expects input as CURSOR.
Or if anyone knows how to get multiple rows using Storedprocedure(by creating in someother way in oracle) please let me know.It would bereally grateful.
Thanks in advance.
------------------
Shiv Sidhaarth
Ranch Hand

Joined: Aug 06, 2001
Posts: 119

cstmt.registerOutParameter(1, Oracle.Types.Cursor).
(resultSet)cstmt.getObject(1);
Amit Agrawal
Ranch Hand

Joined: Aug 23, 2001
Posts: 282
also you need to include
import oracle.jdbc.driver.*;
in your java file to make it compile.
 
jQuery in Action, 2nd edition
 
subject: Calling Oracle Stored Procedure which has parameter as CURSOR
 
Similar Threads
getting the resultset of a stored procedure?
Oracle Procedure problem
getting ResultSet from Java Stored Procedure
Closing cursor in a stored procedure when invoked from a callable statement
Returning Cursor from Stored Procedure