Subject udf's by value (by reference?)
Author vogonjeltzprostetnic
I'm not sure whether I should be posting to this group, since,
technically, I'm coding my Firebird UDF's in Delphi - if I trespass, I
apologize (and would appreciate any directions to a more appropriate
list).

I've written a couple of simple functions meant to serve as declared
constants for my database. The library source:

library DangerfieldLib;

function dsbTrue: Smallint; cdecl;
begin
Result := -1;
end;

function dsbFalse: Smallint; cdecl;
begin
Result := 0;
end;

exports
dsbTrue,
dsbFalse;

begin
end.

No problems creating the library, putting it into place, using it, etc:

SQL> declare external function dsbTrue
CON> returns smallint by value
CON> entry_point 'dsbTrue'
CON> module_name 'DangerfieldLib';
SQL>
SQL> select dsbTrue() from rdb$database;

DSBTRUE
=======
-1

SQL>
SQL> declare external function dsbFalse
CON> returns smallint by value
CON> entry_point 'dsbFalse'
CON> module_name 'DangerfieldLib';
SQL>
SQL> select dsbFalse() from rdb$database;

DSBFALSE
========
0

SQL>

So far, so-so.

Clearly, I'm returning by value. But I'm looking at the Interbase
V6.0 Beta documentation (DevGuide.pdf, SQL Statement and Function
Reference.htm), which seems to indicate that the default is to return
by reference. Would it be more appropriate for me to have my library
functions return by reference instead? If so, any specific
suggestions as to the changes required for my library source? For the
external function declarations? I know it requires the use of
pointers, but I'm having difficulty implementing specific
return-by-reference equivalents of the above functions. I appreciate
what help participants in this list might have to offer.

Thanks,

Marc Benedict