Thanks for the help. I've added the output parameter, but there's so much added automatically below the parameter declaration that I don't understand. Do I need to modify any of these too?
Code:
CREATE PROCEDURE DBName.ProcedureName (
IN IN_CLIENTID DECIMAL(8, 0) ,
IN IN_APPLICATIONID DECIMAL(8, 0) ,
IN IN_USERID DECIMAL(8, 0) ,
OUT ROWS_AFFECTED INTEGER )
DYNAMIC RESULT SETS 1
LANGUAGE SQL
SPECIFIC DBName.ProcedureName
DETERMINISTIC
MODIFIES SQL DATA
CALLED ON NULL INPUT
SET OPTION ALWBLK = *ALLREAD ,
ALWCPYDTA = *OPTIMIZE ,
COMMIT = *ALL ,
DECRESULT = (31, 31, 00) ,
DFTRDBCOL = *NONE ,
DYNDFTCOL = *NO ,
DYNUSRPRF = *USER ,
SRTSEQ = *HEX BEGIN
BEGIN
DECLARE RCOUNT INTEGER ;
DELETE FROM DB.TableName
BLAH
BLAH
BLAH
BLAH;
GET DIAGNOSTICS RCOUNT = ROW_COUNT ;
SET ROWS_AFFECTED = RCOUNT ;
RETURN ROWS_AFFECTED ;
END ;
END ;
I don't believe the multiple BEGIN/END is needed, but probably doesn't really make a difference either. In your example you didn't use RETURN. Is the output param just assumed to be set and then returned? Should I have the delete query inside the inner BEGIN, then my output variable declaration in the outer BEGIN? Does this make a difference?
In my .NET code I use the following to add an output parrameter:
Code:
iDB2Parameter param = new iDB2Parameter("ROWS_AFFECTED",iDB2DbType.iDB2Integer);
param.Direction= ParameterDirection.ReturnValue;
param.Value = 0;
cmd.Parameters.Add(param);
I originally had OUTPUT for the parameter direction but returned -1, which isn't correct so I changed it to ReturnValue. Now that I'm testing my code I'm now getting an error with ReturnValue, telling me that the specified parameters are now incorrect. Any thoughts?
Thanks!
