问题
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;
回答1:
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.
来源:https://stackoverflow.com/questions/22617430/sql0469-in-out-or-inout-not-valid-for-parameter-2-in-procedure