【问题标题】:Enterprise Library ODP.NET call returns ORA-06502: PL/SQL: numeric or value error企业库 ODP.NET 调用返回 ORA-06502:PL/SQL:数字或值错误
【发布时间】:2013-12-12 02:30:22
【问题描述】:

我有以下 Oracle 存储过程:

PROCEDURE SP_ITEMEXISTS(pID IN NUMBER, pExists OUT CHAR) IS
BEGIN
        select CASE count(*) WHEN 0 THEN 'N' ELSE 'Y' END into pExists from items where id = pID;
END SP_ITEMEXISTS;

我使用 ODP.NET 从 Enterprise Library 6.0 调用它,代码如下:

public bool ItemExists(int itemID)
{
    string procedureName = "SP_ItemExists";
    var database = new DatabaseProviderFactory().CreateDefault();
    bool returnValue = false;

    using (OracleCommand command = (OracleCommand)database.GetStoredProcCommand(procedureName))
        {
            command.Parameters.Add("pID", OracleDbType.Int32, itemID, ParameterDirection.Input);
            OracleParameter pExists = command.Parameters.Add("pExists", OracleDbType.Char, ParameterDirection.Output);

            database.ExecuteNonQuery(command);

            if (pExists.Value.ToString().ToUpper() == "Y")
                returnValue = true;
            else
                returnValue = false;
        }

    return returnValue;

}

我收到以下错误: ORA-06502: PL/SQL: 数值或数值错误

从 Oracle SQL Developer 调用存储过程有效。

【问题讨论】:

    标签: c# oracle enterprise-library odp.net enterprise-library-6


    【解决方案1】:

    似乎和这里一样的问题:How to Convert Datetime to OracleTimeStamp

    您必须指定返回值的大小,即

    OracleParameter pExists = command.Parameters.Add("pExists", OracleDbType.Char, 1, null, ParameterDirection.Output);
    

    【讨论】:

      猜你喜欢
      • 2014-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-18
      • 2021-12-26
      • 2014-12-30
      • 1970-01-01
      相关资源
      最近更新 更多