File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes question about default parameters in stored procedure via JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "question about default parameters in stored procedure via JDBC" Watch "question about default parameters in stored procedure via JDBC" New topic
Author

question about default parameters in stored procedure via JDBC

jay akhawri
Ranch Hand

Joined: Nov 28, 2004
Posts: 47
Hi all,

I have a question regading usage of deafult output parametrs in JDBC.
The problem is I am not getting default values as a return of Stored procedure..this is returning NULL.

For example we create a procedure as follows:

CREATE procedure B999EDASOL28XX_SPR25
(
@nch nchar(10) = 'Mars ' OUTPUT ,
@nvc nvarchar(30) = 'Moon ' OUTPUT ,
@ntx ntext = 'Mars lower left of waning crescent Moon.' OUTPUT
)
as
declare @var sql_variant;
set @var = 'qwert12345'
set @var = 12345
select @nch
select @nvc
select @ntx
set @nch = 'Mercury' ;
set @nvc = 'Mercury will have a poor evening appearance in Sept-Oct. '
return (convert(char(20), @var) )
return (convert(int, @var) )


Each of the 3 input/output parameters have a default value
defined in the procedure. When we call the procedure via JDBC, we
prepare and execute the following :

{?=call B999EDASOL28XX_SPR25(?,?,?)}

We do not supply values for any of the input/output parameters,
but SQL Server interprets this as passing NULL instead of using
default value. The result is that all output parameter values are
passed as NULL instead of passing the default value.


I will apriciate your help.

Thanks


Jay
jay akhawri
Ranch Hand

Joined: Nov 28, 2004
Posts: 47
Sorry I forgot to put environment

SQL server 2000 STD and sql server 2005 Std
OS: Windows server 2003
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: question about default parameters in stored procedure via JDBC
 
Similar Threads
Oracle Java Stored Procedure ... Urgent help needed.
Need a disconnected resultset
does Hibernate supports Stored Procedures?
Insertion Values not get stored in sql server using stored procdure in struts2
callable statement question with sybase