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

最后都变了- 提交于 2019-11-27 08:45:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!