Subject Re: [firebird-support] LTRIM and RTRIM failures
Author Milan Babuskov
Rick Debay wrote:
> Table DDL shows the field as VARCHAR.

Oh, I see it now. Well, now you know why top-posting is Bad(tm). I
didn't bother to read rest of the message as you placed the question on top:

http://lists.freebsd.org/pipermail/freebsd-chat/2004-August/002567.html


As for original question...

> Let's test that particular item again
> Select strlen(po.PO), strlen(ltrim(rtrim(po.PO)))
> from RPL_PO po where po.ID = 3144
> Results: 11, 11

I guess this is the problem? However, I'm unable to reproduce it (as
shown below). Perhaps you could give more details: FB version, operating
system, database (and column) charset.

I took FB2.0 and used the EMPLOYEE database:

update employee
set first_name = ' Robert '
where first_name = 'Robert';
commit;

select
'*'||first_name||'*' original, strlen(first_name) len,
'*'||ltrim(first_name)||'*' ltrimmed,
'*'||rtrim(first_name)||'*' rtrimmed,
'*'||ltrim(rtrim(first_name))||'*' bothtrim,
strlen(ltrim(rtrim(first_name)))
from EMPLOYEE
where first_name CONTAINING 'Rob';

returns:

ORIGINAL LEN LTRIMMED RTRIMMED BOTHTRIM STRLEN
------------- --- ----------- ---------- --------- ------
* Robert * 11 *Robert * * Robert* *Robert* 6
*Roberto* 7 *Roberto* *Roberto* *Roberto* 7


Everything looks ok to me.


> Hmmm, let me put quotes around it in order to see leading or trailing
> characters
> select '''' || po.PO || '''' from rpl_po po where po.ID = 3144
> Results: '2895-01V '
>
> Let's test LTRIM and RTRIM and see what they return
> select
> strlen(ltrim(rtrim(' xxx '))),
> ascii_val(substring(' xxx ' from 5 for 1))
> from rdb$database
> Results: 3, 32

This one looks ok too.


--
Milan Babuskov
http://swoes.blogspot.com/
http://www.flamerobin.org