Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting ResultSet from Oracle procedure

 
Amit Da
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
st.execute();
ResultSet rs = (ResultSet) st.getObject(2);
while (rs.next()) {
System.out.println(rs.getString(1));
}
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 ???
Amit
[ September 18, 2003: Message edited by: dalAm ]
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic