Hi there,
I have data coming in a memory stream with an event each time data is added to it. Actually, it is a fax reception.
I want to store data directly to a blob in my database (9i) and I have odac 5.80 installed.
I thought it should be working with this:
procedure TfrmCAPIConfigDetail.FaxStreamToFaxRecord;
Var intCurrentPos : Integer;
intCopyBytes : Integer;
blobSFF : TOraLob;
pBuffer : PByte;
begin
pBuffer := Nil; blobSFF := Nil;
try
FFaxPages := FProtocol.FaxRecvInfo.Pages;
If Assigned (FFaxRecord) then begin
FFaxRecord.Edit;
blobSFF := FFaxRecord.GetLob('FAX');
intCurrentPos := blobSFF.Size;
intCopyBytes := FFaxStream.Size-intCurrentPos;
pBuffer := FFaxStream.Memory; Inc(pBuffer, intCurrentPos);
blobSFF.Write(intCurrentPos, intCopyBytes, pBuffer);
// FFaxRecord.FieldByName('BLOB_SIZE').AsInteger := blobSFF.Size; <- This line is a test. Commented removed, the correct size of the Blob is saved to the DB!
FFaxRecord.Post;
end else SendMessage ('FAX RECORD CLOSED. UNABLE TO UPDATE');
except
On E: Exception do begin
SendMessage ('FAX TRANSFER DATA ERROR: '+E.Message);
FHandler.DisconnectLine($349B);
if Assigned(FfaxRecord) And (FFaxRecord.State=dsEdit) then FFaxRecord.Post;
end;
end;
end;
but it ain't... My Blob is empty! Do you know what am I doing wrong?
Thanks.
I need to append data to a blob... How do I?
-
- Posts: 13
- Joined: Tue 12 Sep 2006 10:02
Tried something better, but it does not change anything...
I've tried also this. But trouble is the same. Blob still empty in the database (But if I query its size [blobSFF.Size] in my software, then it is correct...)
pBuffer := FFaxStream.Memory; Inc(pBuffer, intCurrentPos);
blobSFF := FFaxRecord.GetLob('SFF');
intCurrentPos := blobSFF.Size;
intCopyBytes := FFaxStream.Size-intCurrentPos;
blobSFF.Write(intCurrentPos, intCopyBytes, pBuffer);
blobSFF.FreeLob;
pBuffer := FFaxStream.Memory; Inc(pBuffer, intCurrentPos);
blobSFF := FFaxRecord.GetLob('SFF');
intCurrentPos := blobSFF.Size;
intCopyBytes := FFaxStream.Size-intCurrentPos;
blobSFF.Write(intCurrentPos, intCopyBytes, pBuffer);
blobSFF.FreeLob;
-
- Posts: 13
- Joined: Tue 12 Sep 2006 10:02
Ooops...
It was a bit upside down... I meant:
blobSFF := FFaxRecord.GetLob('SFF');
intCurrentPos := blobSFF.Size;
intCopyBytes := FFaxStream.Size-intCurrentPos;
pBuffer := FFaxStream.Memory; Inc(pBuffer, intCurrentPos);
blobSFF.Write(intCurrentPos, intCopyBytes, pBuffer);
blobSFF.FreeLob;
If I replace the line:
blobSFF.Write(intCurrentPos, intCopyBytes, pBuffer);
with:
var fsSFF: TFileStream;
...
fsSFF.Seek(0, soFromEnd); fsSFF.Write (pBuffer^, intCopyBytes);
...
then the fax is properly received to a file... So I guess i must be wrong with TOraBlob usage somewhere... But where?
blobSFF := FFaxRecord.GetLob('SFF');
intCurrentPos := blobSFF.Size;
intCopyBytes := FFaxStream.Size-intCurrentPos;
pBuffer := FFaxStream.Memory; Inc(pBuffer, intCurrentPos);
blobSFF.Write(intCurrentPos, intCopyBytes, pBuffer);
blobSFF.FreeLob;
If I replace the line:
blobSFF.Write(intCurrentPos, intCopyBytes, pBuffer);
with:
var fsSFF: TFileStream;
...
fsSFF.Seek(0, soFromEnd); fsSFF.Write (pBuffer^, intCopyBytes);
...
then the fax is properly received to a file... So I guess i must be wrong with TOraBlob usage somewhere... But where?
The problem is that TSmartQuery doesn't detect that BLOB field is modified when posting record. Add line
before calling Post method.
Code: Select all
TBlobField(FFaxRecord.FieldByName('FAX')).Modified := True;