Enterprise Library ODP.NET call returns ORA-06502: PL/SQL: numeric or value error

馋奶兔 提交于 2019-12-11 20:28:31

问题


I have the following Oracle Stored Procedure:

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;

I'm calling it from Enterprise Library 6.0 with ODP.NET with the following code:

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;

}

I receive the following error: ORA-06502: PL/SQL: numeric or value error

Calling the Stored Procedure from Oracle SQL Developer works.


回答1:


Seems to be the same problem like here: How to Convert Datetime to OracleTimeStamp

You must specify size of return value, i.e.

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


来源:https://stackoverflow.com/questions/20525707/enterprise-library-odp-net-call-returns-ora-06502-pl-sql-numeric-or-value-erro

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