This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Return Value from Stored Procedure

 
Patrick Mugabe
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a stored procedure with an out parameter so I think it should return a value (correct me if I am wrong). I am calling the stored procedure in my java program.
How do I get the value to my java program. I want to use the returned value in another operation.
 
Brian Mozhdehi
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to do the following.

Assume stmt is the CallableStatement object that is returned from prepareCall() and all input has been set.

stmt.registerOutParameter(<the position of the output parameter>, java.sql.Types.<whatever type it is>);

Then, after execution:

String value = stmt.getString(<the position of the output parameter>);

or whatever type it is, i.e. stmt.getInt(), etc.

Hope that helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic