sagesky36
sagesky36

Reputation: 4692

SQL0469 IN, OUT, or INOUT not valid for parameter 2 in procedure

I'm trying to run a stored procedure against an IBM iSeries running AS400 and getting the above error in my title.

When I type in the following to execute the stored procedure from the System iNavigator tool, it runs fine:

CALL QS36F.HH189P('1','1','')

The first parameter direction is defined in the stored procedure as input, the second output, and the third as output.

Problem is when I try to run the stored procedure from .Net code setting up the parameters. Can someone please help me?

My parameter list is set up as follows:

DB2Command.Parameters.Add("P_STRRRN", iDB2DbType.iDB2Char, 10);
DB2Command.Parameters["P_STRRRN"].Direction = System.Data.ParameterDirection.Input;
DB2Command.Parameters["P_STRRRN"].Value = strRRN;
DB2Command.Parameters.Add("P_LSTRRN", iDB2DbType.iDB2Char, 10);
DB2Command.Parameters["P_LSTRRN"].Value = string.Empty;
DB2Command.Parameters["P_LSTRRN"].Direction = System.Data.ParameterDirection.Output;
DB2Command.Parameters.Add("P_ERRMSG", iDB2DbType.iDB2Char, 70);
DB2Command.Parameters["P_ERRMSG"].Value = string.Empty;
DB2Command.Parameters["P_ERRMSG"].Direction = System.Data.ParameterDirection.Output;

RESOLUTION

Had to declare the commandtext as following:

string cmdtextstring = "CALL QS36F.HH189P" + "('" + strRRN + "',?,?)";

Had to set up the parameters as following:

DB2Command.Parameters.Add("P_LSTRRN", iDB2DbType.iDB2Char, 10);
DB2Command.Parameters["P_LSTRRN"].Value = string.Empty;
DB2Command.Parameters["P_LSTRRN"].Direction = System.Data.ParameterDirection.Output;
DB2Command.Parameters.Add("P_ERRMSG", iDB2DbType.iDB2Char, 70);
DB2Command.Parameters["P_ERRMSG"].Value = string.Empty;

Upvotes: 0

Views: 4607

Answers (1)

WarrenT
WarrenT

Reputation: 4542

If you are passing the parms as string constants, then where would a OUT or INOUT value be returned to? DB2 is expecting you to call the procedure in a way that it can return values into your variables.

Upvotes: 1

Related Questions