isc_blob_info() Call Example

From InterBase

Go Up to Requesting Information About an Open Blob


The following code requests the number of segments and the maximum segment size for a Blob after it is opened, then examines the result buffer:

char blob_items[] = { isc_info_blob_max_segment, isc_info_blob_num_segments};
char res_buffer[20], *p, item;
short length;
SLONG max_size = 0L, num_segments = 0L;
ISC_STATUS status_vector[20];
isc_open_blob2( status_vector,
&db_handle, /* database handle, set by isc_attach_database() */
&tr_handle, /* transaction handle, set by isc_start_transaction() */
&blob_handle, /* set by this function to refer to the Blob */
&blob_id, /* Blob ID of the Blob to open */
0, /* BPB length = 0; no filter will be used */
NULL); /* NULL BPB, since no filter will be used */
if (status_vector[0] == 1 && status_vector[1]) {
isc_print_status(status_vector);
return(1);
}
isc_blob_info(status_vector,
&blob_handle, /* Set in isc_open_blob2() call above. */
sizeof(blob_items), /* Length of item-list buffer. */
blob_items, /* Item-list buffer. */
sizeof(res_buffer), /* Length of result buffer. */
res_buffer); /* Result buffer */
if (status_vector[0] == 1 && status_vector[1]) {
/* An error occurred. */
isc_print_status(status_vector);
isc_close_blob(status_vector, &blob_handle);
return(1);
};
/* Extract the values returned in the result buffer. */
for (p = res_buffer; *p != isc_info_end ;) {
item = *p++
length = (short)isc_portable_integer(p, 2);
p += 2;
switch (item) {
case isc_info_blob_max_segment:
max_size = isc_portable_integer(p, length);
break;
case isc_info_blob_num_segments:
num_segments = isc_portable_integer(p, length);
break;
case isc_info_truncated:
/* handle error */
break;
default:
break;
}
p += length;
};

Advance To: