MS SQL Stored Procedure not returning value (or java needs to alter?) -


can me here have stored procedure not returning value when run sp

running - in java code i'm doing (exec testsp(?) setting 1 input parameter:

on ms sql console running as:

exec testsp @errordescription='' 

on both grounds nothing back.

i no output command completed successfully, idea need change make stored procedure return value?

--testsp

use [testdb] go set ansi_nulls off go set quoted_identifier on go   alter procedure [dbo].[testtbl] @errordescription varchar(40) output     declare @status int     set @status = (                     select status                         testtbl                   )     if @status = 0         set @errordescription = 'ok'     else         set @errordescription = 'fail'     return @status 

is there need change @ java level make work or sp needs change?

java:

stmt = connection.preparecall(sql); stmt.setstring(1, errordesc); stmt.registeroutparameter(2, java.sql.types.varchar); stmt.executeupdate(); string result = stmt.getstring(2);  system.outprintln("result is: "+result); 

what changes need done @ java level make work, i'm getting no result in variable "result"?

to return value need assign variable.

to output parameter, need add output keyword when calling procedure

ie:

declare @ret int, @errordescription varchar(50) exec @ret = testsp @errordescription output select @ret,  @errordescription  

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -