Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How resultset is returned by stored procedure?

 
Hemant Agarwal
Ranch Hand
Posts: 138
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How resultset is returned by stored procedure?
I know that by using Callable Statement we can call stored procedures. But if that stored procedure is returning a resultSet, then how will you handle that resultset?
 
Harshil Mehta
Ranch Hand
Posts: 64
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hemant,

Say you stored procedure is sp_emp for famous Oracle emp table:




Now when you run the procedure from SQL prompt, it will return records for all the employees which is essentially a resultset. That's how the stored procedure can return resultset.

Now in yor java code:


The above code will give you all the employee records in resultset rst. So you can not use the resultset same way as you use for adhoc queries.

hth,
Harshil
 
Hemant Agarwal
Ranch Hand
Posts: 138
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you can not use the resultset same way as you use for adhoc queries.

What do you mean by that?
 
Harshil Mehta
Ranch Hand
Posts: 64
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Hemant,

It was a typo , i meant to say "Now you can use". not "Now you can not use".

--Harshil
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic