Subject Re: [firebird-support] Changing field size to smaller
Author Lucas Franzen
Riho-Rene,

Riho-Rene Ellermaa schrieb:

> I use this script (DETAILS was varchar(210)):
>
> ALTER TABLE corresp add TEMP Varchar(140) CHARACTER SET WIN1252 COLLATE
> WIN1252;
> update corresp set temp=details;

change this to:

UPDATE corresp SET temp = SUBSTRING ( details FROM 1 FOR 140 );

otherwise it can't work.
You cannot pump VARCHAR(210) in VARCHAR(140) fields, the engine itself
will never cut the value for you to make it fit.



> ALTER TABLE corresp drop details;
> ALTER TABLE corresp add details Varchar(140) CHARACTER SET WIN1252
> COLLATE WIN1252;
> update corresp set details=TEMP;

now this will work, since the temp column is just a varchar(140).

> ALTER TABLE corresp drop TEMP;
>
> I can't move the data! Script causes "arithmetic or string truncation
> error" when old Details field data is longer than 140

Luc.