wood burning stoves
The moose likes JDBC and Relational Databases and the fly likes getting ResultSet from Oracle procedure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "getting ResultSet from Oracle procedure" Watch "getting ResultSet from Oracle procedure" New topic

getting ResultSet from Oracle procedure

Amit Da

Joined: Mar 07, 2003
Posts: 16
I am trying to get a ResultSet object by executing a stored procedure in Oracle.
The ResultSet is one of the parameters of this procedure. Typical code:
CallableStatement st = cn.prepareCall("{ call sc_getkeyfieldinfo(?,?) }");
st.setMaxRows(2); //this doesnt do anything
st.setString(1, "T11_2003_1");
st.registerOutParameter(2, OracleTypes.CURSOR);
ResultSet rs = (ResultSet) st.getObject(2);
while (rs.next()) {
How would I get only certain number of rows in my ResultSet ? The setMaxRows on a callable statement did not do anything. Neither does the setFetchSize().
When we get a ResultSet directly by executing a query from a Statement, these maxSize and fetchSize parameters set there do the job and return a ResultSet of specified size(# of rows). But on a CallableStatement it didn't do anything.
Anyone knows how to achieve this ???
[ September 18, 2003: Message edited by: dalAm ]
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
I've run into the same issue with Oracle. The best solution I've found is a bit ugly--you don't rely on Oracle to do it:

You can easily control the number of results to process.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Howdy dalAm,
Welcome to Javaranch!! I have to tell you that your display name does not follow our Naming Policy which we really get our kicks on inforcing. It makes us feel important. Anyway, you can change your display name by clicking here and editing your profile.
Thanks for conforming to the masses and we hope to see you around here often.

GenRocket - Experts at Building Test Data
I agree. Here's the link: http://aspose.com/file-tools
subject: getting ResultSet from Oracle procedure
It's not a secret anymore!