Generating a Blob Parameter Buffer Using API Calls

From InterBase

Go Up to Writing an Application that Requests Filtering


To generate a BPB indirectly, use API calls to create source and target Blob descriptors, and then call isc_blob_gen_bpb2() to generate the BPB from the information in the descriptors. Follow these steps:

  1. Declare two Blob descriptors, one for the source, and the other for the target. For example,
    #include <ibase.h>
    ISC_BLOB_DESC_V2 from_desc, to_desc;
    
  2. Store appropriate information in the Blob descriptors, by calling one of the functions isc_blob_default_desc2(), isc_blob_lookup_desc2(), or isc_blob_set_desc2(), or by setting the descriptor fields directly. The following example looks up the current subtype and character set information for a Blob column named GUIDEBOOK in a table named TOURISM, and stores it into the source descriptor, from_desc. It then sets the target descriptor, to_desc to the default subtype (TEXT) and character set, so that the source data will be converted to plain text.
    isc_blob_lookup_desc2 ( status_vector,
    &db_handle; /* set in previous isc_attach_database() call */
    &tr_handle, /* set in previous isc_start_transaction() call */
    "TOURISM", /* table name */
    "GUIDEBOOK", /* column name */
    &from_desc, /* Blob descriptor filled in by this function call */
    &global);
    if (status_vector[0] == 1 && status_vector[1]) {
    /* process error */
    isc_print_status(status_vector);
    return(1);
    };
    isc_blob_default_desc2 (
    &to_desc, /* Blob descriptor filled in by this function call */
    "", /* NULL table name; it's not needed in this case */
    ""); /* NULL column name; it's not needed in this case */
    
    For more information about Blob descriptors, see Filtering Blob Data.
  3. Declare a character array which will be used as the BPB. Make sure it is at least as large as all the information that will be stored in the buffer.
    char bpb[20];
    
  4. Declare an unsigned short variable into which InterBase will store the actual length of the BPB data:
    unsigned short actual_bpb_length;
    
  5. Call isc_blob_gen_bpb2() to populate the BPB based on the source and target Blob descriptors passed to ­isc_blob_gen_bpb2(). For example,
    isc_blob_gen_bpb2(status_vector,
    &to_desc, /* target Blob descriptor */
    &from_desc, /* source Blob descriptor */
    sizeof(bpb), /* length of BPB buffer */
    bpb, /* buffer into which the generated BPB will be stored */
    &actual_bpb_length); /* actual length of generated BPB */
    

Advance To: