Can someone help me here i have a stored procedure which is not returning any value when i run the SP
Running as - so in my java code i'm doing (exec TestSP(?)
with setting 1 input parameter:
on MS SQL Console running as:
exec TestSP @ErrorDescription=''
On both grounds i get nothing back.
i get no output just Command completed successfully, any idea what i need to change to make this stored procedure return a value?
--TestSP
USE [TESTDB]
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Testtbl] @ErrorDescription VARCHAR(40) OUTPUT
AS
DECLARE @status INT
SET @status = (
SELECT status
FROM Testtbl
)
IF @status = 0
SET @ErrorDescription = 'OK'
ELSE
SET @ErrorDescription = 'FAIL'
RETURN @status
is there anything i need to change at java level to make this work or SP needs to be 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 to be done at java level to make it work, i'm getting no result in variable "result"?