Declaring Blob Filters

From InterBase
Jump to: navigation, search

Go Up to Working with UDFs and Blob Filters


You can use BLOB filters to convert data from one BLOB subtype to another. You can access BLOB filters from any program that contains SQL statements.

BLOB filters are user-written utility programs that convert data in BLOB columns from one subtype to another. The subtype can be either an InterBase subtype or a user-defined one. Declare the filter to the database with the DECLARE FILTER statement. For example:

DECLARE FILTER BLOB_FORMAT
INPUT_TYPE 1 OUTPUT_TYPE -99
ENTRY_POINT 'Text_filter' MODULE_NAME 'Filter_99';

InterBase invokes BLOB filters in either of the following ways:

  • SQL statements in an application
  • interactively through isql.

isql automatically uses a built-in ASCII BLOB filter for a BLOB defined without a subtype, when asked to display the BLOB. It also automatically filters BLOB data defined with subtypes to text, if the appropriate filters have been defined.

To use BLOB filters, follow these steps:

  1. Write the filters and compile them into object code.
  2. Create a shared filter library.
  3. Make the filter library available to InterBase at run time.
  4. Define the filters to the database using DECLARE FILTER.
  5. Write an application that requests filtering.

You can use BLOB subtypes and BLOB filters to do a large variety of processing. For example, you can define one BLOB subtype to hold:

  • Compressed data and another to hold decompressed data. Then you can write BLOB filters for expanding and compressing BLOB data.
  • Generic code and other BLOB subtypes to hold system-specific code. Then you can write BLOB filters that add the necessary system-specific variations to the generic code.
  • Word processor input and another to hold word processor output. Then you can write a BLOB filter that invokes the word processor.

For more information about creating and using BLOB filters, see the Embedded SQL Guide. For the complete syntax of DECLARE FILTER, see the Language Reference Guide.