Databases - Delphi/Firebird - Blobs

Blobs (Binary Large Objects) are used to store large amounts of data, such as In general, it is a BAD idea to store these types of data in blobs, I prefer to store the data as separate files and have the database simply point to them ... but there are exceptions.

In most file oriented databases (such as dBase, FoxPro, Paradox)

In Firebird

Creating Blobs | Reading Blobs - Example | Writing Blobs - Example


Creating Blobs

Blob fields are normally created like this.


Reading Blobs

Delphi 5 provides 2 methods to read tables Either way, the blob can be read using either of these MemoryStream's These next 2 are based on the Delphi help In many ways, this is the simplest example because you don't have to explicitly cast the field


Reading Blobs - Example

This is a relatively complex example - using TMemoryStream.

In one project, the contents of an array is stored in a blob field. The size of the array is data dependent and varies from record to record.

The IBTable_Extensions unit adds several methods to TIBTable and TIBQuery - the only method shown here is BlobToArrayOfSingle.


Writing Blobs

Writing blobs is an issue


Writing Blobs - Example

This code fails Don't forget the array index!


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / Databases / Delphi / Firebird / Blobs.html