The character set HEX is comprised of two octet hexadecimal
characters '00' through 'FF' and has the characteristic that
the contents of data objects with this character set will not
be automatically translated to the display character set when
automatic translation has been enabled.
It may be used in conjunction with the CAST and TRANSLATE
functions to obtain the hexadecimal equivalence of text objects.
Translation to the HEX character set will translate source data
octet by octet into hexadecimal notation.
Translation from the HEX character set will translate from
hexadecimal notation to the destination character set.
For example:
SQL> show character sets
Default character set is DOS_LATINUS
National character set is DOS_LATINUS
Identifier character set is DOS_LATINUS
Literal character set is DOS_LATINUS
Display character set is DOS_LATINUS
Alias RDB$DBHANDLE:
Identifier character set is DEC_MCS
Default character set is DEC_MCS
National character set is DEC_MCS
SQL> show automatic translation
Automatic translation: ON
SQL> create tab latin (f1 char(4) char set win_latin1,
cont> f2 char(4) char set dos_latinus);
SQL> insert into latin value ('AÉÖ','AÉÖ');
1 row inserted
SQL> select f1, cast(f1 as char(8) char set hex),
cont> f2, cast(f2 as char(8) char set hex) from latin;
F1 F2
AÉÖ 41C9D620 AÉÖ 41909920
1 row selected
SQL> select cast (_hex'9099' as char(2) ) from rdb$database;
1 row selected
SQL> select translate (_hex'9099' using rdb$dos_latinus )
Cont> from rdb$database;
1 row selected
The previous example also shows automatic translations between
the literals character set DOS_LATINUS and the field F2
containing WIN_LATIN1, and the subsequent automatic translation
from the F2 field back to the display character set.
The hexadecimal display of the field contents shows that the
actual data stored in the database is different for field f1
and f2 even though the input literals and the output displayed
appears identical.