Generating a Blob Parameter Buffer Directly

From InterBase

Go Up to Writing an Application that Requests Filtering


It is possible to generate a BPB directly.

A BPB consists of the following parts:

  • A byte specifying the version of the parameter buffer, always the compile-time constant, isc_bpb_version1.
  • A contiguous series of one or more clusters of bytes, each describing a single parameter.

Each cluster consists of the following parts:

  • A one-byte parameter type. There are compile-time constants defined for all the parameter types (for example, isc_bpb_target_type).
  • A one-byte number specifying the number of bytes that follow in the remainder of the cluster.
  • A variable number of bytes, whose interpretation depends on the parameter type.
Note:
All numbers in the Blob parameter buffer must be represented in a generic format, with the least significant byte first, and the most significant byte last. Signed numbers should have the sign in the last byte. The API function isc_portable_integer() can be used to reverse the byte order of a number. For more information, see isc_portable_integer().

The following table lists the parameter types and their meaning:

Blob Parameter Buffer Parameter Types
Parameter type Description

isc_bpb_target_type

Target subtype

isc_bpb_source_type

Source subtype

isc_bpb_target_interp

Target character set

isc_bpb_source_interp

Source character set

The BPB must contain isc_bpb_version1 at the beginning, and must contain clusters specifying the source and target subtypes. Character set clusters are optional. If the source and target subtypes are both 1 (TEXT), and the BPB also specifies different source and target character sets, then when data is read from or written to the Blob associated with the BPB, InterBase will automatically convert each character from the source to the target character set.

The following is an example of directly creating a BPB for a filter whose source subtype is –4 and target subtype is 1 (TEXT):

char bpb[] = {
isc_bpb_version1, isc_bpb_target_type,
1, /* # bytes that follow which specify target subtype */
1, /* target subtype (TEXT) */
isc_bpb_source_type,
1, /* # bytes that follow which specify source subtype */
4, /* source subtype*/
};

Of course, if you do not know the source and target subtypes until run time, you can assign those values in the appropriate BPB locations at run time.

Advance To: