Subject RE: [IBO] Reading large blobs
Author Don Schoeman
Never mind, the problem was at the spot where I loaded the data into the
blob. My final routine for loading the data directly into a dynamic array
looks like this:

procedure TSomeClass.GetDataFromBlob(ASource: TIB_Column;
var ADestination: TArrayOfIntegers; ALength: Integer);
begin
SetLength(ADestination, ALength);
with (ASource as TIB_ColumnBinary).Statement.CreateBlobStream(ASource,
bsmRead) do
begin
try
ReadBuffer(ADestination[0], ALength * SizeOf(Integer));
finally
Free;
end;
end;
end;

Simple, easy, effective, fast. :)

-Don


-----Original Message-----
From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]On Behalf
Of Don Schoeman
Sent: 21 September 2005 03:00 PM
To: IBObjects@yahoogroups.com
Subject: [IBO] Reading large blobs


Hi,

I'm trying to read a blob stream directly into an array of integers using
something like this:

procedure GetDataFromBlob(ASource: TIB_Column; var ADestination:
TIntegerArray; ALength: Integer);
var
vBufferPtr: Pointer;
begin
vBufferPtr := @ADestination[0];

with (ASource as TIB_ColumnBinary).Statement.CreateBlobStream(ASource,
bsmRead) do
begin
try
ReadBuffer(vBufferPtr^, ALength * SizeOf(Integer));
finally
Free;
end;
end;
end;

I call this routine like this:
SetLength(vTempArray, 10);
GetDataFromBlob(IB_MyQuery.FieldByName('SOME_FIELD'), vTempArray, 10);

The problem is that the blob's size property says that it's 0 in size and I
get a blob read error. I'm trying to figure out if the problem is where I
insert data into the blob or when I try and read it. If this is not the
correct method of reading the blob, I'll use another method I know works and
that is to create a tempory stream and then put the data into the stream,
and then write it to an array. In this case it's not efficient enough
though, so I'd like to write it directly into the array.

Thx in advance,
Don



___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !




YAHOO! GROUPS LINKS

Visit your group "IBObjects" on the web.

To unsubscribe from this group, send an email to:
IBObjects-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.