Subject RE: [firebird-support] LTRIM
Author Thomas Steinmaurer
Radu,

> Hi,
> Trying to port a script for tables creation from DB2, I stumbled on
> LTRIM, which seems not to exist. I'm using Firebird 1.5 RC3
> Superserv.

LTRIM is available via an UDF (user-defined function) library
called 'ib_udf', but AFAIK the FB 1.5 RC3 binaries don't have
the declaration file 'ib_udf.sql' included, whereas FB 1.0
Final does.

So,

a) make sure that 'ib_udf.dll' is placed in an udf sub-directory
of your Firebird installation.

b) Connect to your database, and execute the following DECLARE
EXTERNAL FUNCTION statement. Adjust the length (per default
80) of the input/output parameters to the expected maximal length
of your [VAR]CHAR fields.

/*****************************************
*
* l t r i m
*
*****************************************
*
* Functional description:
* Removes leading spaces from the input
* string.
* Note: This function is NOT limited to
* receiving and returning only 80 characters,
* rather, it can use as long as 32767
* characters which is the limit on an
* INTERBASE character string.
*
*****************************************/
DECLARE EXTERNAL FUNCTION ltrim
CSTRING(80)
RETURNS CSTRING(80) FREE_IT
ENTRY_POINT 'IB_UDF_ltrim' MODULE_NAME 'ib_udf';

c) Test the UDF with e.g. the following statement.

select ltrim(' test') from rdb$database;



HTH,
Thomas Steinmaurer

The IB LogManager Product Family
Logging/auditing suite for InterBase/Firebird
http://www.iblogmanager.com