Subject Re: [firebird-support] UDF, how to declare them
Author Helen Borrie
At 08:23 AM 25/01/2011, Vander Clock Stephane wrote:
>hello,
>
>in IB_udf2 i see :
>
> * Note: This function is NOT limited to
> * receiving and returning only 255 characters,
> * rather, it can use as long as 32767
> * characters which is the limit on an
> * INTERBASE character string.
>
>DECLARE EXTERNAL FUNCTION ltrim
> CSTRING(255) NULL
> RETURNS CSTRING(255) FREE_IT
> ENTRY_POINT 'IB_UDF_ltrim' MODULE_NAME 'ib_udf';
>
>but when i try to do "select ltrim('...256chars...') from ... when i
>receive an exeption numeric overflow ?
>
>with 255 char it's ok !
>
>did i do something wrong ?

You tried to invoke a UDF whose declared input and output sizes are limited to 255 bytes.

You can declare the "same" UDF more than once, with different-sized parameters and different identifiers, e.g.,

DECLARE EXTERNAL FUNCTION ltrim_LONGER
CSTRING(1022) NULL
RETURNS CSTRING(1022) FREE_IT
ENTRY_POINT 'IB_UDF_ltrim' MODULE_NAME 'ib_udf';

DECLARE EXTERNAL FUNCTION ltrim_EVEN_LONGER
CSTRING(2046) NULL
RETURNS CSTRING(2046) FREE_IT
ENTRY_POINT 'IB_UDF_ltrim' MODULE_NAME 'ib_udf';
...and so on.

./hb