Hello,
I can store 11 characters in a VARCHAR(10) field which causes an error while reading this field from Delphi/FireDAC.
Firebird: 3.0.4
Database : UTF8
Table:
CREATE TABLE XYZ (TEST VARCHAR(10));
Insert data:
insert into XYZ (TEST) values ('0123456789 ');
Note the “space-char” after the “9”.
Select data:
select TEST, char_length(TEST) from XYZ;
Result:
TEST CHAR_LENGTH
0123456789 11
The following insert raise an error which is correct:
insert into XYZ (TEST) values ('01234567890');
But this works:
insert into XYZ (TEST) values ('0123456789 ');
I can add as many spaces as I want.
I believe the “spaces” are stored in the field. If I select data from this table from my Delphi application, I get a string overflow error. Delphi/FireDAC reads the meta data of the table (10 Characters). While reading the real data it gets 11 characters which will raise an exception.
Is this a bug in Firebird? Should the insert with spaces at the end raise an error?
Regards
Mathias Pannier
Hi Mathias,
a workaround for this bug could be a trigger before insert in
which apply the trim to the field value, eg. TEST = TRIM(TEST);
_____________________________________________________________________ --
You received this message because you are subscribed to the Google Groups "firebird-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebird-suppo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/firebird-support/1d6b31f43c2748d7913c2812009efec9%40ubsysteme.de.
Stefano Iraci
Via Carlo Bini, 36
57126 Livorno (LI)
Phone: +39 0586 881 336
www.mccinformatica.it
Hello,
thank You for the fast response. This could be a work around. My “fast” solution was to trim the insert in Delphi code.
Regards
Mathias
Von: firebird...@googlegroups.com <firebird...@googlegroups.com>
Im Auftrag von Stefano Iraci
Gesendet: Dienstag, 28. Mai 2024 11:16
An: firebird...@googlegroups.com
Betreff: Re: [firebird-support] Can store 11 chars in VARCHAR(10) Field?
ACHTUNG: Diese E-Mail stammt von einem externen Absender. Bitte vermeiden Sie es, Anhänge oder externe Links zu öffnen.
To view this discussion on the web, visit https://groups.google.com/d/msgid/firebird-support/83cffe64-4227-47f6-8a09-b1b4dfd94173%40mccinfo.it.