Issue with Array Insert of DBNull

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
nstoev
Posts: 2
Joined: Mon 11 Aug 2008 14:41

Issue with Array Insert of DBNull

Post by nstoev » Mon 02 Apr 2012 13:02

Since dotConnect version 6.7 we have a problem with using bulk insert with dotconnect for Oracle.
The issue did not exist in version 6.5 and currently we cannot upgrade to a later version due to this issue.
This happens when tryning to insert DBNull column in a numeric or Date Oracle column.

Here is a quick example:

using (OracleConnection conn = new OracleConnection())
{ //CREATE TABLE TESTTABLE(TESTCOL NUMBER);
conn.UserId = "...";
conn.Password = "...";
conn.Server = "...";
conn.Open();
OracleCommand insertCommand = new OracleCommand("INSERT INTO TESTTABLE (TESTCOL) VALUES (:t1)") {Connection = conn};
insertCommand.Parameters.Add(new OracleParameter(":t1", OracleDbType.Number) { Value = new object[] { DBNull.Value, DBNull.Value, 1 } });
insertCommand.ExecuteArray(3);
}

The exception thrown is

System.InvalidCastException: Object cannot be cast to DBNull.
at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
at System.Int64.System.IConvertible.ToType(Type type, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Devart.Data.Oracle.OracleParameter.a(bb& A_0, Boolean A_1, Boolean A_2, OracleCommand A_3, Byte[] A_4, Hashtable A_5, an A_6)
at Devart.Data.Oracle.OracleCommand.a(OracleParameterCollection A_0, bb[] A_1, c5 A_2, an A_3)
at Devart.Data.Oracle.OracleCommand.InternalExecute(CommandBehavior behavior, IDisposable disposable, Int32 startRecord, Int32 maxRecords, Boolean nonQuery)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
at Devart.Data.Oracle.OracleCommand.ExecuteNonQuery()

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Post by Pinturiccio » Tue 03 Apr 2012 13:47

We have reproduced the issue and fixed the bug with the InvalidCastException in the OracleCommand.ExecuteArray method when parameter value is an array with the first element DBNull.Value. We will post here when the corresponding build of dotConnect for Oracle is available for download.

Post Reply