Subject Re: [IBO] About Blob Filters
Author Helen Borrie
At 07:10 PM 13/10/2004 +0000, you wrote:

> Hello there!
> I'm trying to use a blob filter in an Interbase Database. So
>far,I have coded the function in a dll, declared the function as a
>blob filter in the database and created a table that holds 3 fields,
>an Id, a Blob subtype -1 and a Blob subtype -2. The Blob filter is
>inteded to pass from blob subtype -1 to -2. How do I call the
>filter? do I need to coded something in the application that
>connects to the database? Any help will be greatly appreciated.

The answer is that you use it much like a UDF. Suppose, for example, you
have the blob filter declared in your database as ConvertMyBlob. You want
to write a stored procedure that converts a blob column named
AMinusOneBlob, that is stored as blob sub_type -1, and output the blob in
your sub_type -2 format. You would do something like this:

create procedure...
returns (
filtered_blob blob sub_type -2,
for select
from MyTable
... ,

Similarly, in DSQL you would do

ConvertMyBlob(AMinusOneBlob) as filtered_blob,
from MyTable

For your own convenience, and for good self-documentation, you should
declare your blobs as your input sub_type, but your blob filter will accept
any blob. The server doesn't know anything about what the blob filter
expects, so it is up to the programmer to store and pass input that the
blob filter can work with.

Remember, too, that any blob filter call is an expression. As with all
expressions, its output is read-only. If your application provides a way
for the user to edit the output and you want to store the result back into
the database as blob sub_type -1, you will need to write and declare
another blob filter that does the reverse conversion, and call that blob
filter in your custom update or insert statement.

The bad news (for you) is that Interbase's blob filter handling is broken
(so I have been told). It was fixed in Firebird 1 (so I have been told).

There is a deprecated SQL syntax in Embedded SQL, which I don't remember at
the moment, that (I have been told) was never implemented in DSQL or PSQL.