Mark Williams wrote:
The FireDAC getData and SetData functions return and set blob data as
a pointer.
RAW data, yes.
I am trying to save a dynamic array of integer "TIntegerArray = array
of Integer" as blob data using these functions.
Can you please show your actual code?
With the GetData function the ABuffLen parameter always returns 4,
which I believe is the size of TIntegerArray. The ADataLen
parameter always returns 0.
How can it
return anything? The declaration you have shown for
GetData() has no output parameters or return value.
In any case, I
suspect (since you didn't show your actual code) that
you are simply writing the array data pointer itself and not the
integer data that the pointer is pointing at, so you are only getting a
pointer back and not the actual integer data.
I believe ABuff is returning a pointer to the array. However, I
cannot figure out how to get from ABuff back to the original
TIntegerArray.
Try something like this (untested):
var
MyIntArray: TIntegerArray;
...
SetData(Column, Pointer(MyIntArray), SizeOf(Integer) *
Length(MyIntArray));
...
SetLength(MyIntArray, BlobSize div SizeOf(Integer));
GetData(Column, Version, Pointer(MyIntArray), SizeOf(Integer) *
Length(MyIntArray), ?, true);
I have no idea what the ADataLen parameter is meant for.
I am currently saving the array to the database using a TBlobField and
createBlobStream.
Again, please show your actual code.
So I will need to work out how to pass in my integer array to the
ABuff parameter as a pointer. Is it as simple as Pointer(MyIntArray)?
Yes.
Do I need to pass in a value for ADataLen and, if so, what?
Yes, of course, otherwise how do you expect it to know how many bytes
the array can hold?
--
Remy Lebeau (TeamB)
Connect with Us