Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Call a stored procedure
12-21-2010, 08:14 AM
Post: #1
Call a stored procedure
We assume that the Connection is known as :

Connection conn;

then

String query = "begin thePackage.theProcedure(?,?,?); end;";
CallableStatement cs = conn.prepareCall(query);
cs.setString(1, "string parameter"); // #1 is INPUT
cs.setInt(2, 1); // #2 is INPUT
cs.registerOutParameter(2, Types.INTEGER); // and OUTPUT
cs.registerOutParameter(3, Types.INTEGER); // #3 is OUTPUT
cs.execute();

int output_parm2 = cs.getInt(2); // get the result from OUTPUT #2
int output_parm3 = cs.getInt(3); // get the result from OUTPUT #3
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:



Send your comments, Suggestions or Queries regarding this site at info@tutorials4u.net

Copyright © 2010 Tutorials4u.net All Rights Reserved