aspose file tools*
The moose likes JDBC and the fly likes stored procedure in sybase that returns 1 output parameter and return code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "stored procedure in sybase that returns 1 output parameter and return code" Watch "stored procedure in sybase that returns 1 output parameter and return code" New topic
Author

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

Martin Lira
Ranch Hand

Joined: May 26, 2004
Posts: 97
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30324
    
150

Martin,
Sun has an example with the sample syntax.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Martin Lira
Ranch Hand

Joined: May 26, 2004
Posts: 97
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30324
    
150

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: stored procedure in sybase that returns 1 output parameter and return code