ExecuteArray and nullable int32 or nullable decimal values

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
HCRoman
Posts: 55
Joined: Wed 12 Aug 2009 05:47

ExecuteArray and nullable int32 or nullable decimal values

Post by HCRoman » Fri 24 Jun 2011 10:03

Hi devart team,

i have trouble with nullable int32 and nullable decimal parameters during ExecuteArray calls.

(I have not checked all other datatypes yet...)

The parameter has correct settings
param.IsNullable = true
and the values in the array also nullable types

I get an exception
InvalidCastException

{"Ungültige Umwandlung von \"System.Decimal\" in \"System.Nullable`1[[System.Decimal, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]\"."}


mscorlib.dll!System.Convert.DefaultToType(System.IConvertible value, System.Type targetType, System.IFormatProvider provider) + 0x4dc Bytes
mscorlib.dll!decimal.System.IConvertible.ToType(System.Type type, System.IFormatProvider provider) + 0x25 Bytes
mscorlib.dll!System.Convert.ChangeType(object value, System.Type conversionType, System.IFormatProvider provider) + 0x1fd Bytes
Devart.Data.Oracle.dll!Devart.Data.Oracle.OracleParameter.a(ref Devart.Data.Oracle.ay A_0 = {Devart.Data.Oracle.ay}, bool A_1 = true, bool A_2 = false, Devart.Data.Oracle.OracleCommand A_3 = {Devart.Data.Oracle.OracleCommand}, byte[] A_4 = {byte[871344]}, System.Collections.Hashtable A_5 = Count = 0, Devart.Data.Oracle.ah A_6 = {Devart.Data.Oracle.a1}) + 0x7b1 Bytes
Devart.Data.Oracle.dll!Devart.Data.Oracle.OracleCommand.a(Devart.Data.Oracle.OracleParameterCollection A_0 = {Devart.Data.Oracle.OracleParameterCollection}, Devart.Data.Oracle.ay[] A_1 = {Devart.Data.Oracle.ay[5]}, Devart.Data.Oracle.ch A_2 = {Devart.Data.Oracle.av}, Devart.Data.Oracle.ah A_3 = {Devart.Data.Oracle.a1}) + 0x130 Bytes
Devart.Data.Oracle.dll!Devart.Data.Oracle.OracleCommand.InternalExecute(System.Data.CommandBehavior behavior = Default, System.IDisposable disposable = {Devart.Data.Oracle.bj}, int startRecord = 0, int maxRecords = 0, bool nonQuery = true) + 0xb63 Bytes
Devart.Data.dll!Devart.Common.DbCommandBase.ExecuteDbDataReader(System.Data.CommandBehavior behavior = Default, bool nonQuery = true) + 0x153 Bytes
Devart.Data.Oracle.dll!Devart.Data.Oracle.OracleCommand.ExecuteNonQuery() + 0x4c Bytes
Devart.Data.Oracle.dll!Devart.Data.Oracle.OracleCommand.ExecuteArray(int iters = 12102) + 0xcc Bytes
> RLV!KVNo.Komponenten.fachlich.DezentraleAbrechnung.RLV.EntityModel.RlvModelExtensions.
RlvInsertByCommand.DoExecute() Zeile 902 + 0xd5 Bytes C#


Any help or bugfix??

I am using the last release build version:

6.30.160.0

Roman

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 27 Jun 2011 16:20

Could you please tell us how we should modify this code to reproduce the error?

Code: Select all

//CREATE TABLE TEST (
//  ID NUMBER(38),
//  COL1 NUMBER(38),
//  COL2 NUMBER(38,9),
//  CONSTRAINT PK_TEST PRIMARY KEY (ID));

    using (OracleConnection conn = new OracleConnection(connStr)) {
        conn.Open();
        OracleCommand cmd = conn.CreateCommand();
        cmd.CommandText = "insert into test values (:id, :col1, :col2)";
        cmd.Parameters.Add("id", OracleDbType.Integer).Value = new Int32[] { 1 };
        cmd.Parameters.Add("col1", OracleDbType.Integer).Value = new Int32?[] { null };
        cmd.Parameters.Add("col2", OracleDbType.Number).Value = new Decimal?[] { null };
        cmd.ExecuteArray(1);
    }

HCRoman
Posts: 55
Joined: Wed 12 Aug 2009 05:47

ExecuteArray and nullable int32 or nullable decimal values

Post by HCRoman » Tue 28 Jun 2011 07:50

Hi Shalex,

Yes,

append any not null value in your nullable datatype array!

Roman

Code: Select all

//CREATE TABLE TEST ( 
//  ID NUMBER(10), 
//  COL1 NUMBER(5), 
//  COL2 NUMBER(13,2), 
//  CONSTRAINT PK_TEST PRIMARY KEY (ID)); 

    using (OracleConnection conn = new OracleConnection(connStr)) { 
        conn.Open(); 
        OracleCommand cmd = conn.CreateCommand(); 
        cmd.CommandText = "insert into test values (:id, :col1, :col2)"; 
        cmd.Parameters.Add("id", OracleDbType.Integer).Value = new Int32[] { 1, 2 }; 
        cmd.Parameters.Add("col1", OracleDbType.Integer).Value = new Int32?[] { null, 55555}; 
        cmd.Parameters.Add("col2", OracleDbType.Number).Value = new Decimal?[] { null, 1.22m}; 
        cmd.ExecuteArray(2); 
    }

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 28 Jun 2011 14:12

We have reproduced the error. We will investigate the issue and notify you about the results as soon as possible.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 29 Jun 2011 07:52

The bug with OracleCommand.ExecuteArray() for nullable value types is fixed. We will post here when the corresponding build is available for download.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 11 Jul 2011 06:40

New build of dotConnect for Oracle 6.30.185 is available for download!
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): http://secure.devart.com/ .

For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=21452 .

Post Reply