Subject | Re: [firebird-support] external function lpad |
---|---|
Author | Alin |
Post date | 2008-06-14T07:26:34Z |
My fault: i didn't read the release notes...
Actually, i can use the internal function lpad.
Thank you, Alin
Actually, i can use the internal function lpad.
Thank you, Alin
----- Original Message -----
From: Helen Borrie
To: firebird-support@yahoogroups.com
Sent: Saturday, June 14, 2008 2:29 AM
Subject: Re: [firebird-support] external function lpad
At 01:00 AM 14/06/2008, you wrote:
>Hi,
>
>i'm using Firebird 2.1.0.17798.
And you haven't read the release notes, right? Actually, you NEED to. ;-)
>I declared in a database the following function:
>
>DECLARE EXTERNAL FUNCTION RTRIM
> CSTRING (255)
> RETURNS CSTRING (255) FREE_IT
> ENTRY_POINT 'IB_UDF_rtrim' MODULE_NAME 'ib_udf';
>
>and it worked!
Indeed it does. Firebird 2.1 doesn't have an internal function named RTRIM.
>I can't understand why the next one doesn't work!
>
>DECLARE EXTERNAL FUNCTION lpad
> CSTRING(255) NULL, INTEGER, CSTRING(1) NULL
> RETURNS CSTRING(255) FREE_IT
> ENTRY_POINT 'IB_UDF_lpad' MODULE_NAME 'ib_udf';
>
>Can somebody help me to declare this function?
Firebird 2.1 has an internal function named LPAD (name is case-insensitive). So, if you want to keep using the external function, you will have to drop the current declaration and declare it with the same name in upper case enclosed in double quotes. The engine will then choose the UDF and not call the internal function. This is documented.
DECLARE EXTERNAL FUNCTION "LPAD"
CSTRING(255) NULL, INTEGER, CSTRING(1) NULL
RETURNS CSTRING(255) FREE_IT
ENTRY_POINT 'IB_UDF_lpad' MODULE_NAME 'ib_udf';
But this is not a great idea, IMO, if you can avoid it. The internal function will work with your existing function calls if you simply drop the UDF declaration altogether.
The only gotcha with this is if you are calling this UDF from legacy compiled PSQL code modules (triggers or procedures). In that case you will have (a) dependencies and (b) old compiled code that didn't know about the internal function. The solution here is to recompile the modules (using ALTER TRIGGER or ALTER PROCEDURE with the entire source in the statement). Do I need to remind you to do this in exclusive mode after a complete database shutdown.....?
./heLen
------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.100 / Virus Database: 270.3.0/1501 - Release Date: 6/13/2008 6:33 AM
--
I am using the free version of SPAMfighter for private users.
It has removed 259 spam emails to date.
Paying users do not have this message in their emails.
Get the free SPAMfighter here: http://www.spamfighter.com/len
[Non-text portions of this message have been removed]