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!

Empty BLOB with InitialLOBFetchSize = -1 returns null

User_B6ZH9Mar 10 2022

If a table contains an empty BLOB, OracleDataReader.GetValues() and OracleDataReader.GetValue() will just return null for that value, when InitialLOBFetchSize is set to -1 (not even DbNull, but just null). When specifying 0 or a positive value for InitialLOBFetchSize I get an empty byte array as expected.
Is there some way to configure this, that I get the fast loading for other BLOBs, and not null for empty BLOBs?
And is there a reason when GetValue() would return null, or should it always be just the database value or DbNull (and this is just a bug in Oracle)?
Test data:

CREATE TABLE FOO (BLOB1 BLOB);
declare
 emptyBlob BLOB;
begin
 dbms_lob.createtemporary(emptyBlob, false);
 INSERT INTO FOO VALUES (emptyBlob);
end;

Executing this code, GetValue(0) returns null.

var cmd = new OracleCommand("SELECT BLOB1 FROM FOO", conn)
{
 InitialLOBFetchSize = -1,
};
var reader = cmd.ExecuteReader();
reader.Read();
Trace.Assert(reader.GetValue(0) != null);

Tested with Oracle.ManagedDataAccess 21.5.0 and Oracle.ManagedDataAccess.Core 3.21.50 with 19c server.

This post has been answered by Alex Keh-Oracle on Mar 11 2022
Jump to Answer
Comments
Post Details
Added on Mar 10 2022
1 comment
337 views