Subject Re: Firebird blank spaces on unused chars in a field?
Author Ard Biesheuvel
--- In firebird-php@yahoogroups.com, "ArnoldGamboa.com"
<arnoldgamboadotcom@y...> wrote:
>
> Correct me if I'm wrong. I think that firebird fills the remaining
> parts of the field with blank spaces. Say I have a varchar(50) field.
> I entered a record with, say, 10 characters. I noticed that when I
> retrieve the data, my textfield has the inputed character plus blank
> spaces which I suspect represents the other 40 spaces.
>

As Lester indicated, this only occurs with CHAR() fields, not with
VARCHAR() fields. This complies with what the SQL specs dictate.

While some other DBMSs do some weird stuff with spaces in [VAR]CHAR()
fields, in Firebird it's very simple:
- a CHAR(x) fields stores x characters, so if you fetch from it you
get 50 characters (this doesn't necessarily mean 50 characters are
being stored on disk)
- a VARCHAR(x) field stores up to x characters, so if you fetch from
it, you get exactly the (number of) characters you inserted. This is
true even for trailing spaces.

What is stored or what is sent on the wire has nothing to do with this.

Personally, I don't use ADODB, but I assume some trim()'ing is going
on in there. Therefore, the results going through ADODB might be
different.

--
Ard