[英]Oracle.ManagedDataAccess.Client.OracleException - ORA-01722: invalid number
I am working in .NET 4.5 C#, oracle 11g environment. 我正在.NET 4.5 C#,oracle 11g环境中工作。
I am experiencing peculiar behaviour, when I call following SQL statement from code by using datacontext 当我使用datacontext从代码中调用以下SQL语句时,我遇到了特殊的行为
I get ORA-01722: invalid number
我收到
ORA-01722: invalid number
StackTrace: 堆栈跟踪:
at Corp.DataServices.ExecuteQueryHandler.HandleQueryException(Exception exception) in c:\dev\CCTech Main\Corp\Corp.Conveyancing.DataServices\FluentData.cs:line 4022
at Corp.DataServices.ExecuteQueryHandler.ExecuteQuery(Boolean useReader, Action action) in c:\dev\CCTech Main\Corp\Corp.Conveyancing.DataServices\FluentData.cs:line 3993
at Corp.DataServices.DbCommand.QueryMany[TEntity,TList](Action`2 customMapper) in c:\dev\CCTech Main\Corp\Corp.Conveyancing.DataServices\FluentData.cs:line 3857
at Corp.DataServices.DbCommand.QueryMany[TEntity](Action`2 customMapper) in c:\dev\CCTech Main\Corp\Corp.Conveyancing.DataServices\FluentData.cs:line 3882
at Corp.Dashboard.Controllers.HomeController.GetInstructionsJson(String id) in c:\dev\CCTech Main\Corp\Corp.Conveyancing.Dashboard\Controllers\HomeController.cs:line 65
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41()
Now to the peculiar part. 现在到特殊的部分。
When I execute same exact sql directly from PL/SQL it works just fine 当我直接从PL / SQL执行完全相同的sql时,效果很好
What is going on? 到底是怎么回事? There aren't any casts in the statement.
语句中没有任何强制转换。 I must be missing something obvious here.
我一定会在这里遗漏一些明显的东西。
You can't pass in a parameter in this way. 您不能以这种方式传递参数。 When you do that, it will render the SQL as something like this:
当您这样做时,它将把SQL渲染成这样:
WHERE productid IN ('1,2,3,4,5')
Which will attempt to cast the value as a single string to a number. 它将尝试将值作为单个字符串转换为数字。 Instead you can either:
相反,您可以:
^[0-9][\\,0-9]*$
^[0-9][\\,0-9]*$
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.