SQL0469 IN、OUT 或 INOUT 对过程中的参数 2 无效 [英] SQL0469 IN, OUT, or INOUT not valid for parameter 2 in procedure
问题描述
我正在尝试针对运行 AS400 的 IBM iSeries 运行存储过程,并在我的标题中收到上述错误.
I'm trying to run a stored procedure against an IBM iSeries running AS400 and getting the above error in my title.
当我输入以下内容以从 System iNavigator 工具执行存储过程时,它运行良好:
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.
问题是当我尝试从设置参数的 .Net 代码运行存储过程时.有人可以帮我吗?
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 + "',?,?)";
必须设置如下参数:
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;
推荐答案
如果您将参数作为字符串常量传递,那么 OUT 或 INOUT 值会返回到哪里?DB2 期望您以一种可以将值返回到您的变量中的方式调用该过程.
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.
这篇关于SQL0469 IN、OUT 或 INOUT 对过程中的参数 2 无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!