File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Returning value and CallableStatement

 
Carey Brown
Ranch Hand
Pie
Posts: 1074
11
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a stored procedure that invokes the SQL "return (42)" at the point of completion. (This is Sybase if that makes any difference.) The following is the JDBC I put together to call the stored procedure. The three method calls that use and index work, the three commented out lines that use the column name do not. I have a strong need to be able to use the column name version for flexibility with other stored procedures that have very long parameter lists of which only a subset is needed. If I try to use the index version for argument one, and the named version for the remainder I get a run time error saying that I can't mix them. Actually, the name version runs but it appears that arguments are shifted when they get to the stored procedure. I've tried all sorts of permutations of the registerOutParameter() line, but no luck.



Any insights you could give me would be appreciated.
Thanks,
Carey
 
Mahesh Bogadi
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also need the answer to this question.

Can be use a name instead of ? to name the parameter?

e.g. { ret = call ( ?, ?, ? ) };

callablestatement .getString ("ret" )
 
Martin Vajsar
Sheriff
Pie
Posts: 3747
62
Chrome Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know, pure JDBC doesn't support named parameters. You have to use the question marks for all parameters.

Some JDBC drivers have methods that allow to use named parameters, but this is an extension incompatible with JDBC standard, so it won't work with another JDBC driver.

Edit: the original question concerned passing function/procedure parameters by name. I don't know whether that is supported as part of the JDBC standard, I always pass parameters by position - that always works.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic