Subject Slight UDF Mystery . . .
Author vogonjeltzprostetnic
(Firebird 1.5.1 from a Win98 client, XP Pro SP2 server)

I've declared an external function:

SQL> DECLARE EXTERNAL FUNCTION GUID_OCTETS
CON> RETURNS CHAR(16) CHARACTER SET OCTETS FREE_IT
CON> ENTRY_POINT 'GenGUID'
CON> MODULE_NAME 'BinGUID.dll';
SQL>

No problem from ISQL so far (AFAIK):

SQL> show function;
GUID_OCTETS
SQL> show function GUID_OCTETS;

Function GUID_OCTETS:
Function library is BinGUID.dll
Entry point is GenGUID
Returns FREE_IT CHAR(16) CHARACTER SET OCTETS
SQL>select * from rdb$functions;

RDB$FUNCTION_NAME GUID_OCTETS
RDB$FUNCTION_TYPE <null>
RDB$QUERY_NAME <null>
RDB$DESCRIPTION <null>
RDB$MODULE_NAME BinGUID.dll
RDB$ENTRYPOINT GenGUID
RDB$RETURN_ARGUMENT 0
RDB$SYSTEM_FLAG <null>


SQL>

Queries don't work, though:

SQL> select GUID_OCTETS from rdb$database;
Statement failed, SQLCODE = -206

Dynamic SQL Error
-SQL error code = -206
-Column unknown
-GUID_OCTETS
-At line 1, column 20.
.
.
.
SQL> insert into GUID_TEST (BIN_GUID)
CON> values(GUID_OCTETS);
Statement failed, SQLCODE = -206

Dynamic SQL Error
-SQL error code = -206
-Column unknown
-GUID_OCTETS
-At line 2, column 10.
SQL>

If it's any help, here's the Delphi 5 (update pack 1) source for the
library:

library BinGUID;

uses
ib_util, ComObj, ActiveX;

function GenGUID: PGUID; cdecl;
begin
Result := PGUID(ib_util_malloc(SizeOf(Result^)));
try
OleCheck(CoCreateGUID(Result^));
except
FillChar(Result^, SizeOf(Result^), 0);
end;
end;

exports
GenGUID;

begin
end.

Although I've been a developer for a number of years now, I'm kind of
a newbie to Firebird (and it's not as though I've written an enormous
number of dll's, either). So if I've made a laughable blunder (or
two), please be gentle. :-)

-Marc Benedict