NullReferenceException in bulk insert of user data type

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
miwi
Posts: 17
Joined: Thu 27 Jul 2006 10:42

NullReferenceException in bulk insert of user data type

Post by miwi » Thu 22 Dec 2011 14:56

Hi there,

testing 6.60.258 we found there is an issue we did not have in 6.10.135, the version we use up to now.

Consider a user defined Oracle type

Code: Select all

create or replace type money as object (mv number, mc char(3))
Trying to insert a record into a simple table using bulk insert fails if said value is null:

Code: Select all

using (var connection = new OracleConnection(connectString))
using (var command = connection.CreateCommand())
{
  connection.Open();
  var moneyType = OracleType.GetObjectType("money", connection);
  command.CommandText = "insert into mw_bugtest (m) values (:m)";
  command.Parameters.Add("m", OracleDbType.Object);
  var m = new OracleObject(moneyType);
  m.IsNull = true;
  command.Parameters["m"].Value = new[] {m};
  command.ExecuteArray(1);
}
throws an exception with the following stacktrace:

Code: Select all

System.NullReferenceException: Object reference not set to an instance of an object.
   at Devart.Data.Oracle.cq..ctor(ah A_0, OracleType A_1, OracleConnection A_2, Int32 A_3)
   at Devart.Data.Oracle.OracleParameter.a(OracleDbType A_0, Object A_1, Object A_2, Byte[] A_3, Hashtable A_4, Int32 A_5, Int32 A_6, Int32 A_7, Int32 A_8, Int32 A_9, Boolean A_10, OracleConnection A_11, ParameterDirection A_12, String A_13, ah A_14, Boolean& A_15)
   at Devart.Data.Oracle.OracleParameter.a(a0& A_0, Boolean A_1, OracleConnection A_2, Byte[] A_3, Hashtable A_4, ah A_5, Boolean& A_6, Int32 A_7)
   at Devart.Data.Oracle.OracleCommand.a(ag A_0, Int32 A_1, OracleParameterCollection A_2, ah A_3, Boolean& A_4)
   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()
   at Devart.Data.Oracle.OracleCommand.ExecuteArray(Int32 iters)
   at ConsoleApplication1.Program.TestBulkInsert() in D:\mydev\ConsoleApplication1\ConsoleApplication1\Program.cs:line 55
Replacing

Code: Select all

m.IsNull = true;
with a not null value

Code: Select all

m["mc"] = "EUR";
m["mv"] = 100;
works as expected.

A workaround we found was setting the ObjectTypeName of the parameter explicitly:

Code: Select all

command.Parameters["m"].ObjectTypeName = moneyType.Name;
but that's not a nice solution.

Would you please fix this? Thanks.

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

Post by Pinturiccio » Tue 27 Dec 2011 13:51

We have reproduced the issue. We will investigate it and notify you as soon as possible.

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

Post by Pinturiccio » Fri 13 Jan 2012 08:31

We have fixed the bug with NullReferenceException when executing a query with OracleObject, OracleArray, OracleTable parameters with Null value.
The new build of dotConnect for Oracle 6.60.283 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=23129

miwi
Posts: 17
Joined: Thu 27 Jul 2006 10:42

Post by miwi » Mon 16 Jan 2012 08:01

Pinturiccio wrote:We have fixed the bug
Thank you, I can confirm the bug is fixed in 6.60.283.

Post Reply