Overview of working with BLOBs
Blobs are binary large objects. Blobs can hold
large blocks of text, images, or other large data objects. In
Firebird, blobs are primarily accessed through blob identifiers.
The blob handling functions are:
creates a new blob to which data can be added and subsequently
stored in a table
This function adds
additional data to a blob that has been opened fro writing with
This function cancels a
blob that has been created for writing. Any contents are discarded
This function opens a
blob for reading with the blob_get function
This function retrieves a
sequential chunk of data from the blob
This function closes a
blob that is open for reading or writing
This function imports a
file into a blob in a single operation
This function echoes the
contents of a blob directly to the browser
This function provides
information about the size and type of a blob
Blob ID's and Blob handles
It is important to distinguish between blob ID's
and blob handles, as the two are very different and easily confused.
A blob ID is an 8-byte string that
identifies the blob inside the database. It is the blob ID that is
stored into tables and retrieved from it.
A blob handle is a blob that has been opened
for access. Typically a blob handle is obtained by first retrieving
a blob ID from the database and then opening the blob by passing the
blob ID to the blob_open function.
Note that you cannot rely on blob ID's being fixed
for during the blob's lifetime. The blob ID changes on two
If a blob is created and closed it
gets assigned a temporary blob ID. Only when the ID is inserted into
a table, and the insert operation is committed, a different,
permanent blob ID will be assigned.
This permanent blob ID can change during each
backup – restore cycle. One can only be sure that a blob ID
stays the same within a single transaction.