Subject Re: [firebird-support] How do I trim white space from a field.
Author Paul Vinkenoog
Hi Fred,

> I have been able to do this type of thing with other engines:
>
> select c_cid from cusmas where trim(c_cid) like '100' and it will
> work because trim is removing trailing spaces.
>
> So my question is (finally) how do I trim white space from a field?

Firebird doesn't have an internal TRIM function (yet), but two
standard UDFs called ltrim and rtrim (left and right trim). For the
above case, rtrim would do the job.

Just to be complete: you must declare a UDF to the database before you
can use it, like this:

DECLARE EXTERNAL FUNCTION rtrim
CSTRING(80)
RETURNS CSTRING(80) FREE_IT
ENTRY_POINT 'IB_UDF_rtrim' MODULE_NAME 'ib_udf';

If your strings are > 80 chars, change the declaration accordingly.


Greetings,
Paul Vinkenoog