Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Bulk operations output parameters missing null support

15394059-4fef-41f0-9d7a-d134a1e85fa0Jul 31 2023 — edited Jul 31 2023

Hi, I encountered a bug when trying to use bulk operations (using ArrayBindCount) with output parameters. When executed command returns null into output parameter and the parameter is integer or decimal, the returned value is actually a default, instead null or System.DbNull, in this case 0.

Here is a sample code to reproduce the error, using latest Oracle.ManagedDataAccess.Client:

using var conn1 = CreateConnection();

await conn1.OpenAsync();

using var cmd1 = conn1.CreateCommand();
cmd1.CommandText = "begin select null into :Ret from dual where :Id > 0; end;";

var dummyArray = Enumerable.Range(1, 10).ToArray();

var p1 = cmd1.CreateParameter();
p1.ParameterName = "Id";
p1.DbType = DbType.Int32;
p1.Direction = ParameterDirection.InputOutput;
p1.Value = dummyArray;
cmd1.Parameters.Add(p1);

var p2 = cmd1.CreateParameter();
p2.ParameterName = "Ret";
p2.DbType = DbType.Int32;
p2.Direction = ParameterDirection.Output;
p2.Value = Enumerable.Range(1, dummyArray.Length).Select(p => (int?)null).ToArray();
cmd1.Parameters.Add(p2);


if (cmd1 is Oracle.ManagedDataAccess.Client.OracleCommand ocmd)
{
    ocmd.BindByName = true;
    ocmd.ArrayBindCount = dummyArray.Length;                
}

await cmd1.ExecuteNonQueryAsync();

Console.WriteLine(p2.Value);

after running the code, I would expect the output parameters value to by array with 10 elements of nullable<int> or System.DbNull, but I get array of zeros

Can this by fixed or my code needs to be fixed somehow?

Regards

Kris

Comments
Post Details
Added on Jul 31 2023
1 comment
714 views