Subject Re: [firebird-support] blank character
Author Mark Rotteveel
> Mark Rotteveel schrieb am 09.05.2011 um 17:52 (+0200):
>
> > So if I insert a String 'A ' in VARCHAR of length 5 or larger, I
> > should get that exact same string back when queried it should not trim
> > the spaces. Firebird BTW does exactly that.
>
> SQL> create table chartest (c char(10), vc varchar(10));
> SQL> insert into chartest values ( 'abc ', 'abc ');
> SQL> select c, char_length(c), vc, char_length(vc) from chartest;
>
> C CHAR_LENGTH VC CHAR_LENGTH
> ========== ============ ========== ============
> abc 10 abc 6
>
> This is:
>
> Firebird/x86/Windows NT (access method),
> version "WI-V2.5.0.26074 Firebird 2.5"
>
> > I would sooner say that if you want to save trailing spaces
> > consistently (as in: what goes in comes out again), then you use
> > VARCHAR, if you want everything to have the same length (padded with
> > spaces), then you use CHAR.
> >
> > I do agree with you that trailing spaces are considered insignificant
> > in comparisons (SQL92 section 8.2).
>
> In the above example, the two values do compare equal:
>
> select
> c, char_length(c),
> vc, char_length(vc)
> from chartest
> where c = vc;

This all confirms what I said :)

Mark
--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone