This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
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

calling stored procedure

 
Sanjeev Kaushik
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am calling a stored procedure(Oracle 9.2.04) from Java. My offshore team tested this code using stmt.registerOutParameter and it worked for them. Now at client site, it did not work. I changed it by setInt and it worked. Please let me know if it is a known bug.
============================================================
CallableStatement stmt=null;
try {
stmt= conn.prepareCall("call MoveToTemp(?)");
//stmt.registerOutParameter(1, Types.INTEGER, aiApplicationId);
stmt.setInt(1, aiApplicationId);
stmt.execute();
stmt.close();
} catch (Exception ex) {
ex.printStackTrace();
}
============================================================
 
M Givney
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sanjeev,
It's difficult to say without seeing the stored procedure's signature, but there are a couple of things you can check.
The registerOutParameter() method is used to capture parameters that are defined as OUT parameters in the stored procedure. See if the procedure has an OUT parameter as the first parameter.
Also, I would guess if there is a OUT parameter, they would try to use the out parameter...check down in the code a little ways..do you see any calls that look like: int <varname> = stmt.getInt(1); ?
The code you commented out:
stmt.registerOutParameter(1, Types.INTEGER, aiApplicationId);
will compile but will fail at runtime if there isn't an OUT param in the proc @ position 1. This code tells the statement that there is an Out param in position 1 of type integer and with a scale of whatever aiApplicationId equates to.
Hope that helps.
Regards,
Matt
[ April 20, 2004: Message edited by: M Givney ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic