Blob Segment Length (Embedded SQL Guide)

From InterBase

Go Up to How are Blob Data Stored?


When you define a Blob in a table, you specify the expected size of Blob segments that are to be written to the column in the Blob definition statement. The segment length you define for a Blob column specifies the maximum number of bytes that an application is expected to write to or read from any Blob in the column. The default segment length is 80. For example, the following column declaration creates a Blob with a segment length of 120:

EXEC SQL CREATE TABLE TABLE2
(
Blob1 Blob SEGMENT SIZE 120;
);

InterBase uses the segment length setting to determine the size of an internal buffer to which it writes Blob segment data. Normally, you should not attempt to write segments larger than the segment length you defined in the table; doing so may result in a buffer overflow and possible memory corruption.

Specifying a segment size of n guarantees that no more than n number of bytes are read or written in a single Blob operation. With some types of operations, for instance, with SELECT, INSERT, and UPDATE operations, you can read or write Blob segments of varying length.

In the following example of an INSERT CURSOR statement, specify the segment length in a host language variable, segment_length, as follows:

EXEC SQL
INSERT CURSOR BCINS VALUES (:write_segment_buffer
INDICATOR :segment_length);

For more information about the syntax of the INSERT CURSOR statement, see Language Reference Guide.

Advance To: