SQLMemTable: Embedded BDE Alternative
In-Memory SQL Database for Delphi / C++Builder

BLOB fields use
Previous  Top  Next


Use of BLOB fields in SQLMemTable is the same as in TTable component.
BLOB fields compression is transparent, so you can easily use it if you store large amounts of data in BLOB fields.

Use TSQLMemBlobStream to access or modify the value of a BLOB field in an SQLMemTable.
TSQLMemBlobStream is a stream object that provides services allowing applications to read from or write to field objects that represent Binary large object (BLOB) fields.

TSQLMemBlobStream allows objects that have no specialized knowledge of how data is stored in a BLOB field to read or write such data by employing the uniform stream mechanism.

To use a BLOB stream, create an instance of TSQLMemBlobStream, use the methods of the stream to read or write the data, and then close the BLOB stream. Do not use the same instance of TSQLMemBlobStream to access data from more than one record. Instead, create a new TSQLMemBlobStream object every time you need to read or write BLOB data on a new record.


The following example reads the data from a memo field into a blob stream and displays it in a memo control.

procedure TForm1.Button2Click(Sender: TObject);
Buffer: PChar;
MemSize: Integer;
Stream: TSQLMemBlobStream;
Stream := TSQLMemBlobStream.Create(MySQLMemTable.FieldByName('Notes') as TBlobField, bmRead);
MemSize := Stream.Size;
Inc(MemSize); Make room for the buffer's null terminator.
Buffer := AllocMem(MemSize); Allocate the memory.
Stream.Read(Buffer^, MemSize); Read Notes field into buffer.
Memo1.SetTextBuf(Buffer); Display the buffer's contents.
FreeMem(Buffer, MemSize);

© AidAim Software SQLMemTable: