Subject | Re: [firebird-support] UDF with string functions |
---|---|
Author | Helen Borrie |
Post date | 2004-07-20T00:30:11Z |
At 04:45 PM 19/07/2004 +0000, you wrote:
your varchars (up to a limit of 32,765 bytes).
SUBSTRING() internal function.
You can use the ib_udf function strlen() to get the length of a string.
need. For example, here's the standard declaration for LTRIM in ib_udf.sql:
DECLARE EXTERNAL FUNCTION ltrim
CSTRING(80)
RETURNS CSTRING(80) FREE_IT
ENTRY_POINT 'IB_UDF_ltrim' MODULE_NAME 'ib_udf';
If 80 is ok for your purposes, declare it "as is". Then, later, you find
you need a longer string for a certain stored procedure. Just add another
declaration:
DECLARE EXTERNAL FUNCTION ltrim200
CSTRING(200)
RETURNS CSTRING(200) FREE_IT
ENTRY_POINT 'IB_UDF_ltrim' MODULE_NAME 'ib_udf';
Now you have two ltrim functions in your database: one (ltrim) with an
80-byte max. size and the other (ltrim200) with a 200-byte max.
/heLen
>Hi, all.UDFs can't return multiple values.
>
>I need an UDF which returns me a substring and the
>string length of a VARCHAR.
>The SUBSTR function in ib_udf.dl doesn't supportDeclare string UDFs with cstring sizes that are long enough to accommodate
>VARCHARs longer than 80 chars (though it is suposed
>in the documentation).
your varchars (up to a limit of 32,765 bytes).
>What I wan't to do is extracting PKs from a stringIf you're using Firebird, don't use a UDF for substring, use the
>which is delivered by my app.
SUBSTRING() internal function.
You can use the ib_udf function strlen() to get the length of a string.
>Any ideas or a link to a UDF which has the describedWith any string UDFs, declare UDFs with the max. string sizes that you
>functionality?
need. For example, here's the standard declaration for LTRIM in ib_udf.sql:
DECLARE EXTERNAL FUNCTION ltrim
CSTRING(80)
RETURNS CSTRING(80) FREE_IT
ENTRY_POINT 'IB_UDF_ltrim' MODULE_NAME 'ib_udf';
If 80 is ok for your purposes, declare it "as is". Then, later, you find
you need a longer string for a certain stored procedure. Just add another
declaration:
DECLARE EXTERNAL FUNCTION ltrim200
CSTRING(200)
RETURNS CSTRING(200) FREE_IT
ENTRY_POINT 'IB_UDF_ltrim' MODULE_NAME 'ib_udf';
Now you have two ltrim functions in your database: one (ltrim) with an
80-byte max. size and the other (ltrim200) with a 200-byte max.
/heLen