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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Reading OracleBlob throws exception when InitialLOBFetchSize is > 0

User_5RTMFNov 19 2020 — edited Nov 19 2020

Hello,
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.

Result:
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);
}
}

This post has been answered by Alex Keh-Oracle on Nov 23 2020
Jump to Answer

Comments

Post Details

Added on Nov 19 2020
7 comments
323 views