• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

stored procedure in sybase that returns 1 output parameter and return code

 
Martin Lira
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gurus,
I have a stored procedure for sybase. It takes 3 input parameters and returns 1 error code and 1 output parameter.

Can anybody please give me the syntax for calling this stp from CallableStatement and viewing the return and output parameters.

Thanks,
Martin
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin,
Sun has an example with the sample syntax.
 
Martin Lira
Ranch Hand
Posts: 97
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,
Thanks for sending me the link, I looked at the ex usage of Callable but it only has 1 OUT parameter. Correct my syntax if the stp is returning a return code.
CallableStatement cs =
con.prepareCall("{? = call accountlogin(?,?,?)}");
cs.registerOutParameter(1, Types.INTEGER) //return code
cs.setString(2,theuser);
cs.setString(3,password);
cs.registerOutParameter(4,Types.DATE);

cs.executeQuery();
int return_code = cs.getInt(1);
Date lastLogin = cs.getDate(4);

thanks,
ML
[ July 28, 2004: Message edited by: Martin Lira ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin,
Your example, shows one out parameter and one return value. If that is what your stored procedure does, it is correct.

This page shows the difference between parameters and return values.
 
Wiliam Carvalho
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very helpfull post, thanks!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic