c# - Oracle.ManagedDataAccess.Client.OracleException - ORA-01722: invalid number -
i working in .net 4.5 c#, oracle 11g environment.
i experiencing peculiar behaviour, when call following sql statement code using datacontext
i ora-01722: invalid number
stacktrace:
@ corp.dataservices.executequeryhandler.handlequeryexception(exception exception) in c:\dev\cctech main\corp\corp.conveyancing.dataservices\fluentdata.cs:line 4022 @ corp.dataservices.executequeryhandler.executequery(boolean usereader, action action) in c:\dev\cctech main\corp\corp.conveyancing.dataservices\fluentdata.cs:line 3993 @ corp.dataservices.dbcommand.querymany[tentity,tlist](action`2 custommapper) in c:\dev\cctech main\corp\corp.conveyancing.dataservices\fluentdata.cs:line 3857 @ corp.dataservices.dbcommand.querymany[tentity](action`2 custommapper) in c:\dev\cctech main\corp\corp.conveyancing.dataservices\fluentdata.cs:line 3882 @ corp.dashboard.controllers.homecontroller.getinstructionsjson(string id) in c:\dev\cctech main\corp\corp.conveyancing.dashboard\controllers\homecontroller.cs:line 65 @ lambda_method(closure , controllerbase , object[] ) @ system.web.mvc.actionmethoddispatcher.execute(controllerbase controller, object[] parameters) @ system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary`2 parameters) @ system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary`2 parameters) @ system.web.mvc.async.asynccontrolleractioninvoker.actioninvocation.invokesynchronousactionmethod() @ system.web.mvc.async.asynccontrolleractioninvoker.<begininvokesynchronousactionmethod>b__39(iasyncresult asyncresult, actioninvocation innerinvokestate) @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresult`2.callenddelegate(iasyncresult asyncresult) @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresultbase`1.end() @ system.web.mvc.async.asyncresultwrapper.end[tresult](iasyncresult asyncresult, object tag) @ system.web.mvc.async.asynccontrolleractioninvoker.endinvokeactionmethod(iasyncresult asyncresult) @ system.web.mvc.async.asynccontrolleractioninvoker.asyncinvocationwithfilters.<invokeactionmethodfilterasynchronouslyrecursive>b__3f() @ system.web.mvc.async.asynccontrolleractioninvoker.asyncinvocationwithfilters.<>c__displayclass48.<invokeactionmethodfilterasynchronouslyrecursive>b__41()
now peculiar part.
when execute same exact sql directly pl/sql works fine
what going on? there aren't casts in statement. must missing obvious here.
you can't pass in parameter in way. when that, render sql this:
where productid in ('1,2,3,4,5')
which attempt cast value single string number. instead can either:
- pass values array using table valued parameter. i've not done before pretty sure it's possible, example how use array/table parameter oracle (odp.net 10g) via ado.net/c#?)
- forget using parameters , use string concatenation. not great idea (sql injection etc.) simple do. validate input regex (and assuming don't have spaces between numbers) use match input (slightly modified comment @liufa):
^[0-9][\,0-9]*$
Comments
Post a Comment