Subject | RE: [firebird-support] Writing UDF with Freepascal |
---|---|
Author | Svend Meyland Nicolaisen |
Post date | 2008-01-02T09:21:28Z |
Additionally, when you declare the UDF as FREE_IT you must have allocated
the return buffer with the ib_util_malloc method.
If you remove FREE_IT from the declaration of the UDF you must be sure that
Wert1 dosn't go out of scope when the functions returns. In other words
Wert1 must be declared as a global variable.
/Svend
________________________________
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Helen Borrie
Sent: 1. januar 2008 22:36
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] Writing UDF with Freepascal
At 05:46 AM 2/01/2008, you wrote:
UTF_UPPER name 'UTF_UPPER';
You're declaring
ENTRY_POINT 'UTF_UPPER' MODULE_NAME 'udf_upper';
./heLen
the return buffer with the ib_util_malloc method.
If you remove FREE_IT from the declaration of the UDF you must be sure that
Wert1 dosn't go out of scope when the functions returns. In other words
Wert1 must be declared as a global variable.
/Svend
________________________________
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Helen Borrie
Sent: 1. januar 2008 22:36
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] Writing UDF with Freepascal
At 05:46 AM 2/01/2008, you wrote:
>Hello everybody,The UDF exports
>
>I've tried to write with Freepascal a UDF for Firebird.
>
>library udf_upper;
>
>{$mode DELPHI}{$H+}
>{$PACKRECORDS C}
>
>uses
> Classes
> { you can add units after this };
>
>
>function UTF_UPPER(wert : PChar) : PChar; cdecl; export;
>begin
> wert1 := String(wert);
>//Some String operations
> result := PChar(wert1);
>end;
>
>exports
> UTF_UPPER name 'UTF_UPPER';
>
>begin
>
>end.
>
>I registered it in Firebird by using:
>
>DECLARE EXTERNAL FUNCTION WIDEUPPER
>CSTRING(32000)
>RETURNS CSTRING(32000) FREE_IT
>ENTRY_POINT 'UTF_UPPER' MODULE_NAME 'udf_upper';
>
>Everything works ok, but when I try to use the function in a
>SQL-Statement, it just says:
>
>ISC ERROR CODE:335544343
>
>ISC ERROR MESSAGE:
>invalid request BLR at offset 63
>function WIDEUPPER is not defined
>module name or entrypoint could not be found
>
>I absolutely don't know why...
>
>Can somebody please help me?
UTF_UPPER name 'UTF_UPPER';
You're declaring
ENTRY_POINT 'UTF_UPPER' MODULE_NAME 'udf_upper';
./heLen