Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
532 views
in Technique[技术] by (71.8m points)

.net - 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;
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...