This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 31st, when you will be able to use this site as normal.

    Forum Stats

  • 3,890,899 Users
  • 2,269,649 Discussions


Reading OracleBlob throws exception when InitialLOBFetchSize is > 0

User_5RTMF Member Posts: 5
edited Nov 19, 2020 3:10PM in ODP.NET


using ODP.NET, I'm having issue when reading blob field as stream (using GetOracleBlob),

I don't know where to report a bug, so putting it here.

i'm using Oracle.ManagedDataAccess Nuget package version 19.10.0 (latest)

1. Have InitialFetchLOBSize is > 0

2. get blob stream with 'GetOracleBlob'

3. read first N bytes, but less than InitialFetchLOBSize

4. then read next portion of bytes, which would go over InitialFetchLOBSize cached bytes.



it throws exception

"Source array was not long enough. Check srcIndex and length, and the array's lower bounds."

  at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)

  at System.Array.Copy(Array sourceArray, Int64 sourceIndex, Array destinationArray, Int64 destinationIndex, Int64 length)

  at OracleInternal.ServiceObjects.OracleBlobImpl.Read(Int64 locatorOffset, Int64 numBytesToRead, Int64 outBufferOffset, Byte[]& outBuffer)

  at Oracle.ManagedDataAccess.Types.OracleBlob.Read(Byte[] buffer, Int32 offset, Int32 count)

To give example with specific numbers:

- InitialFetchLOBSize=32,

- read first 16 bytes (or any number under 32, or you can just set Position to 16, or 31, doesn't matter)

- read next 32 bytes (so requested data chunk will read some of already cached data and some new)

sample code:

command.CommandText = @"select BLOB from table";

command.InitialLOBFetchSize = 32;

var reader = command.ExecuteReader()) {

while (reader.Read()) {

  if (reader.IsDBNull(0)) continue;

  using (var blob = reader.GetOracleBlob(0)) {

    blob.Position = 16;

    // this will throw exception

    blob.Read(buffer, 0, 64);



Best Answer