isc_put_segment()

From InterBase

Go Up to API Function Reference


Writes a Blob segment.

Syntax

 ISC_STATUS isc_put_segment(
 ISC_STATUS *status_vector,
 isc_blob_handle *blob_handle,
 unsigned short seg_buffer_length,
 char *seg_buffer);
Parameter Type Description

status_vector

ISC_STATUS *

Pointer to the error status vector

blob_handle

isc_blob_handle *

Pointer to the handle of the Blob to which you want to write; use isc_create_blob2() to set a value for this handle

seg_buffer_length

unsigned short

Length of the Blob segment buffer

seg_buffer_address

char *

Pointer to the Blob segment buffer that contains data for writing

Description

isc_put_segment() writes a Blob segment in seg_buffer_address to a Blob previously created and opened with isc_create_blob2().

If a Blob filter was specified when the Blob was created, then each segment is filtered before storing the result into the Blob.

The behavior of isc_put_segment() depends on what call preceded it. If the most recent call was to isc_create_blob() or isc_create_blob2(), then a call to isc_put_segment() writes the first segment of the Blob. If the most recent call was to isc_put_segment(), then it writes the next segment.

You can write bitmaps and other binary files directly, without filtering, unless you intend to change from one format to another, say from GEM to BMP. You can also store compressed bitmaps directly in a database, in formats such as JPG (JPEG), BMP (Windows native bitmaps), or GIF (CompuServe Graphic Interchange Format).

You can store bitmaps in your database in row-major or column-major order.

You cannot update a Blob directly. If you want to modify Blob data, you must do one of the following:

  • Create a new Blob.
  • Read the old Blob data into a buffer where you can edit or modify it.
  • Write the modified data to the new Blob.
  • Prepare and execute an UPDATE statement that will modify the Blob column to contain the Blob ID of the new Blob, replacing the old Blob’s Blob ID.

For more information about creating and writing Blob data, see Working with Blob Data.

Note: To read a segment that you wrote with a call to isc_put_segment(), you must close the Blob with isc_close_blob(), and then open it with isc_open_blob2().

Example

The following example reads a segment of one Blob and writes it to another Blob:

get_status = isc_get_segment(status, &from_blob, &seg_len, 80, buffer);
if (status[0] == 1 && status[1]) {
isc_print_status(status);
return(1);
}
if (get_status != isc_segstr_eof)
write_status = isc_put_segment(status, &to_blob, seg_len, buffer);
if (status[0] == 1 && status[1]) {
isc_print_status(status);
return(1);
}

Return value

isc_put_segment() returns the second element of the status vector. Zero indicates success. A nonzero value indicates an error. For InterBase errors, the first element of the status vector is set to 1, and the second element is set to an InterBase error code.

To check for an InterBase error, examine the first two elements of the status vector directly. For more information about examining the status vector, see Handling Error Conditions.

See Also


Advance To: