我从C#调用我的存储过程,我得到以下异常:
ORA-06550:第1行第7栏:
PLS-00306:调用'MY_PROC'时参数的数量或类型错误 ORA-06550:第1行第7栏:
PLS-00306:调用'MY_PROC'时参数的数量或类型错误 ORA-06550:第1行第7栏:
PL / SQL:忽略语句
由于我的程序有57个参数,因此要知道问题究竟在哪里并不容易。 有没有办法得到更详细的信息?
注意:但参数类型和数字似乎匹配!
以下是我的存储过程参数:
Var_PE_... IN NUMBER(8,0),
Var_PE_... IN NUMBER(4,0),
Var_PE_... IN NUMBER(3,0),
Var_PE_... IN DATE,
Var_PE_... IN DATE,
Var_PE_... IN NUMBER(2,0),
Var_PE_... IN NUMBER(4,0),
Var_PE_... IN NUMBER(4,0),
Var_PE_... IN NUMBER(8,0),
Var_PE_... IN NUMBER(7,0),
Var_PE_... IN VARCHAR2(1 BYTE),
Var_PE_... IN CHAR(1 BYTE),
Var_PE_... IN NUMBER(15,0),
Var_PE_... IN VARCHAR2(25 BYTE),
Var_PE_... IN VARCHAR2(25 BYTE)
Var_PE_... IN VARCHAR2(25 BYTE),
Var_PE_... IN VARCHAR2(25 BYTE),
Var_PE_... IN NUMBER(5,0),
Var_PE_... IN VARCHAR2(25 BYTE),
Var_PE_... IN VARCHAR2(25 BYTE),
Var_PE_... IN NUMBER(5,0),
Var_PE_... IN NUMBER(5,0),
Var_PE_... IN VARCHAR2(11 BYTE),
Var_PE_... IN NUMBER(2,0),
Var_PE_... IN CHAR(2 BYTE),
Var_PE_... IN VARCHAR2(17 BYTE),
Var_PE_... IN DATE,
Var_PE_... IN DATE,
Var_PE_... IN DATE,
Var_PE_... IN NUMBER(12,5),
Var_PE_... IN NUMBER(9,2),
Var_PE_... IN NUMBER(3,0),
Var_PE_... IN NUMBER(9,2),
Var_PE_... IN CHAR(2 BYTE),
Var_PE_... IN CHAR(3 BYTE),
Var_PE_... IN NUMBER(3,0),
Var_PE_... IN NUMBER(7,2),
Var_PE_... IN NUMBER(3,0),
Var_PE_... IN NUMBER(9,2),
Var_PE_... IN NUMBER(9,2),
Var_PE_... IN NUMBER(10,0),
Var_PE_... IN VARCHAR2(49 BYTE),
Var_PE_... IN CHAR(1 BYTE),
Var_PE_... IN CHAR(1 BYTE),
Var_PE_... IN CHAR(6 BYTE),
Var_PE_... IN CHAR(1 BYTE),
Var_PE_... IN NUMBER(9,2),
Var_PE_... IN VARCHAR2(13 BYTE),
Var_PE_... IN NUMBER(2,0),
Var_PE_... IN VARCHAR2(2 BYTE),
Var_PE_... IN DATE,
Var_PE_... IN DATE,
Var_PE_... IN VARCHAR2(1 BYTE),
Var_PE_... IN NUMBER(2,0),
Var_PE_... IN VARCHAR2(20 BYTE),
Var_PS... OUT VARCHAR2,
Var_PS... OUT VARCHAR2
这是我从c#:
调用此过程l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Date, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Date, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Date, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Date, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Date, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Double, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Double, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Double, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Double, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Double, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Double, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Double, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Double, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Date, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Date, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.Int32, 0, "PE_..."));
l_Params.Add(CreateInputDbParameter(DbType.AnsiString, 0, "PE_..."));
l_Params.Add(CreateOutputDbParameter(DbType.AnsiString, 2000, "PS_..."));
l_Params.Add(CreateOutputDbParameter(DbType.AnsiString, 2000, "PS_..."));
ExecuteStoreProcedure("MY_PROC", l_Params);
创建参数的主代码:
public DbParameter CreateInputDbParameter(DbType typeParam, int sizeparam,
string nameParam, object valueParam)
{
DbParameter DbParam = Parameter;
DbParam.DbType = typeParam;
DbParam.Size = sizeparam;
DbParam.Direction = ParameterDirection.Input;
DbParam.ParameterName = nameParam;
if (valueParam == null)
{
DbParam.Value = DBNull.Value;
}
else
{
DbParam.Value = valueParam;
}
return DbParam;
}
public DbParameter CreateOutputDbParameter(DbType typeParam, int sizeparam, string nameParam)
{
DbParameter DbParam = Parameter;
DbParam.DbType = typeParam;
DbParam.Size = sizeparam;
DbParam.Direction = ParameterDirection.Output;
DbParam.ParameterName = nameParam;
return DbParam;
}
答案 0 :(得分:0)
如果输出
,则需要将参数方向设置为ParameterDirection.OutputOracleParameter test=
new OracleParameter("testparameter", OracleDbType.Varchar2);
test.Direction = ParameterDirection.Output;
cmd.Parameters.Add(test);
如果是输入,则将其设置为ParameterDirection.Input
检查参数的大小,声明时不给出大小。而且参数的类型也很重要。例如,您NUMBER(15,0)
映射DbType.Int32
,NUMBER(3,0)
映射DbType.Double
您正在尝试使用ADO.NET基类连接oracle,您知道即使System.Data.OracleClient
也已弃用。
不推荐使用System.Data.OracleClient中的类型。类型是 在.NET Framework的第4版中受支持,但将在a中删除 未来发布。 Microsoft建议您使用第三方Oracle 提供商。
您最好使用Oracle Data Provider for .NET,大部分错误都将得到解决。