Declaring a blob UDF

By: Borland Staff

Abstract: Declaring a blob UDF

The documentation example in the Programmers Guide for 
declaring a blob UDF is wrong.

How do I really declare a blob UDF?

The information in this article applies to:
* InterBase v4.x
* InterBase v5.x

The Programmers Guide states that "A UDF that returns a Blob
does not actually define a return value.  Instead, a pointer to a structure
describing the Blob to return must be passed as the last input parameter 
to the UDF."

The example given does not have a returns  clause in
it.  If you run this example it will result in a token unknown error, because
the returns  clause is required when declaring a UDF.

The way to workaround this is to use an undocumented clause.   This clause 
tells InterBase to use one of the input parameters as the return value.

The syntax for this undocumented clause is "returns parameter n" where n is 
the number of the input parameter that is to be used as the return value.

Here is an example demonstrating this clause:

declare external function Blob_plus_Blob
  Returns parameter 3
  entry_point 'BlobCat' 
  module_name 'BlobConcat.dll';

This declaration tells InterBase that the third parameter is to be used as the
return value from this UDF.

Server Response from: ETNASC04