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

At August 11, 2004, 20:19, Fred Gordon wrote:


> I am converting a system from informix to firebird. I had to pull a
> bunch of data over from informix as chars.
> So I have a white space problem.

> select c_cid from cusmas where c_cid like '100' does not return a
> record but:
> select c_cid from cusmas where c_cid = '100' does return the 100 record.
> select c_cid from cusmas where c_cid like '100 ' (with spaces)
> returns a record.

> 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?

CHARs will have, and save, the trailing white spaces. VARCHARs don't.
And, certain comparisons don't take into considerations trailing
spaces(i.e.: =), and other will consider trailing spaces(i.e.: LIKE).
This behavior is part of the SQL standards.

--
Best regards,
Daniel Rail
Senior System Engineer
ACCRA Group Inc. (www.accra.ca)
ACCRA Med Software Inc. (www.filopto.com)