![](/img/trans.png)
[英]ORA-06502: PL/SQL: numeric or value error with stored procedure and ASP.NET MVC
[英]Enterprise Library ODP.NET call returns ORA-06502: PL/SQL: numeric or value error
我有以下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調用存儲過程即可。
好像是這里一樣的問題: 如何將Datetime轉換為OracleTimeStamp
您必須指定返回值的大小,即
OracleParameter pExists = command.Parameters.Add("pExists", OracleDbType.Char, 1, null, ParameterDirection.Output);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.