C # - ODP.NET and ora-01475 must redraw cursor to change binding type of binding variable

I get ora-01475

whenever I try to insert a null value into a column (of type DateTime

) after some records have already been inserted that have real date values.

I am using a constructor OracleParameter

that takes a name and value as an object (I assume the datatype is then inferred from the datatype of the object), but since sometimes the value of my parameter is null, it is set as String

, so it throws this error.

I don't want to use a constructor that explicitly transfers the datatype because I heavily use reflection to create an object OracleCommand

and its parameters.

How can I redraw the cursor (as the error suggests) if I find this situation?
Does anyone else come across this and have a solution?

0


source to share


1 answer


Have you tried using nullable types?



            DateTime? myDate;
            //Code to set myDate value...
            string sql = "[your SQL]"
            using (OracleCommand command = new SqlCommand(sql, cn))
            {
                OracleParameter param = new OracleParameter(":Name",myDate);
                command.Paerameters.add(param);
                command.ExecuteNonQuery();
            }

      

+1


source







All Articles