Subject Re: Rif: [firebird-support] Chararacter set NONE to ISO8859_1
Author Mark Rotteveel
On Wed, 22 Jul 2015 21:09:12 -0300, "Aldo Caruso
aldo.caruso@...
[firebird-support]" <firebird-support@yahoogroups.com> wrote:
> Raffaele,
>
> thanks for your answer.
> The question is what prevents data loss in the first procedure ?
> Suppose the filed in question is
>
> FIRST_NAME VARCHAR(60) CHARACTER SET NONE
>
> so lets create a temporary field
>
> TMP_NAME VARCHAR(60) CHARACATER SET ISO8859_1
>
> and then lets fill it
>
> UPDATE TABLE1 SET TMP_NAME = CAST(FIRST_NAME AS VARCHAR(60)
> CHARACTER SET OCTETS)
>
> Whichever character (from 0 to 255) were in FIRST_NAME would be blindly
> copied to TMP_NAME.
> This has the same effect as assuming that the characters in FIRST_NAME
> where loaded as ISO8859_1, so simply changing FIRST_NAME type from NONE
> to ISO8859_1 would be equivalent.

No, if you alter the character set of an existing column, then the old
data will remain in its old format and format version, and will only be
converted when selected/queried. Leading potentially to conversion errors
at run time (there are a number of bytes in ISO-8859-1 that are not valid
to use). If you create a new column and transfer the data, the validity
check is done at the moment of transfer and you can fix any problems at
that time.

The important difference between these two is the time the conversion
error might occur.

Mark