Search code examples
.netoraclec#-4.0parametersodp.net

Anonymous Oracle Parameters?


I am trying to input data into an Oracle database. This is going to be a stored procedure that takes several parameters... I mean like 27 parameters (don't ask, I didn't design it)...

Now I have to somehow populate the parameters of this stored procedure... Most of the parameters that the stored proc takes are VARCHARS... but a couple are char or Date or Number values... Now, all the values will be string values from the function I am calling (I will be reading an XML doc and populating the values from there). Can I just input the Parameters through OracleParameterCollection.Add(Object) without having to Cast the objects and convert them to the correct Oracle Data Type? This is just a shot in the dark. Otherwise I am going to be writing a massive case switch statement (Kill myself now!). I think I know better though...

Since this is due Monday, I better start writing the case switch statement since I suspect that my request is impossible.

Thanks.


Solution

  • Yes, for many pairs of data types, Oracle will automatically convert the data for you. This certainly includes the conversion from strings to dates and numbers. With dates, you must however make sure, that the string has the format of the current NLS date settings.

    Appendix A of the ODP.NET documentation lists the supported conversions in table A-2.