我已将所有参数与oracle存储过程相匹配,但它们看起来是一样的,但我仍然遇到此错误。
这是使用Oracle.ManagedDataAccess.Client.OracleCommand
OracleCommand command = new OracleCommand(sqlCommand, this.Connection);
command.CommandType = CommandType.StoredProcedure;
command.Transaction = this.Transaction;
command.Parameters.Add(Common.CreateOracleParameterObj("STR_SCHEMANAME", OracleDbType.Varchar2, schema.Name, ParameterDirection.Input));
command.Parameters.Add(Common.CreateOracleParameterObj("INT_CREATEDBYID", OracleDbType.Int32, schema.CreatedBy, ParameterDirection.Input));
command.Parameters.Add(Common.CreateOracleParameterObj("DATE_CREATIONDATE", OracleDbType.Date, System.DateTime.Now, ParameterDirection.Input));
command.Parameters.Add(Common.CreateOracleParameterObj("INT_APPROVEDBYID", OracleDbType.Int32, schema.ApprovedBy, ParameterDirection.Input));
command.Parameters.Add(Common.CreateOracleParameterObj("DATE_APPROVALDATE", OracleDbType.Date, System.DateTime.Now, ParameterDirection.Input));
command.Parameters.Add(Common.CreateOracleParameterObj("INT_STATUSID", OracleDbType.Int32, schema.StatusId, ParameterDirection.Input));
command.Parameters.Add(Common.CreateOracleParameterObj("STR_DESCRIPTION", OracleDbType.Varchar2, schema.Description, ParameterDirection.Input));
command.Parameters.Add(Common.CreateOracleParameterObj("INT_NEWVERSIONTYPE", OracleDbType.Int32, Convert.ToInt32(schema.SaveAs), ParameterDirection.Input));
command.Parameters.Add(Common.CreateOracleParameterObj("IN_MAJVER", OracleDbType.Int32, Convert.ToInt32(schema.MajorVersion), ParameterDirection.Input));
command.Parameters.Add(Common.CreateOracleParameterObj("IN_MINVER", OracleDbType.Int32, Convert.ToInt32(schema.MinorVersion), ParameterDirection.Input));
command.Parameters.Add(Common.CreateOracleParameterObj("INT_RESULT", OracleDbType.Int32, 0, ParameterDirection.Output));
command.ExecuteNonQuery();
public static OracleParameter CreateOracleParameterObj(string parameterName, OracleDbType oracleType, object Val, ParameterDirection parameterDirection)
{
OracleParameter _oracleParameter = new OracleParameter();
_oracleParameter.ParameterName = parameterName;
_oracleParameter.OracleDbType = oracleType;
_oracleParameter.Direction = parameterDirection;
if ((parameterDirection == ParameterDirection.Input) || (parameterDirection == ParameterDirection.InputOutput))
{
switch (oracleType)
{
case OracleDbType.Date:
_oracleParameter.Value = (System.DateTime)Val;
break;
case OracleDbType.Int32:
_oracleParameter.Value = (Int32)Val;
break;
case OracleDbType.Varchar2:
_oracleParameter.Value = Val as String;
break;
default:
break;
}
}
return _oracleParameter;
}
create or replace PROCEDURE "USP_SCHEMAS_ADDNEWVERSION"
(
STR_SCHEMANAME IN VARCHAR,
INT_CREATEDBYID IN NUMBER,
DATE_CREATIONDATE IN DATE,
INT_STATUSID IN NUMBER,
INT_APPROVEDBYID IN NUMBER,
DATE_APPROVALDATE IN DATE,
STR_DESCRIPTION IN VARCHAR,
INT_NEWVERSIONTYPE IN INT,
INT_RESULT OUT NUMBER,
IN_MAJVER IN NUMBER,
IN_MINVER IN NUMBER
) AS
答案 0 :(得分:0)
原因是参数的顺序。我认为,顺序没有任何区别,但是当我重新命令参数与存储过程相同时,它就有用了。
后来,我发现使用以下内容可以解决这个问题,并且不需要确切的排序: -
oracleCommand.BindByName = true;