Implicit casting for character and graphic constants

Implicit casting (or weak typing) is an alternative way to parse character or graphic constants for applications that expect these constants to be assigned the data types CHAR or GRAPHIC.

Enablement

To enable implicit casting for character and graphic constants, set the DB2_COMPATIBILITY_VECTOR registry variable to hexadecimal value 0x100 (bit position 9), then stop and restart the instance:
db2set DB2_COMPATIBILITY_VECTOR=100
db2stop
db2start
To activate all the compatibility features for Oracle applications, set the DB2_COMPATIBILITY_VECTOR to ORA, then stop and restart the instance:
db2set DB2_COMPATIBILITY_VECTOR=ORA
db2stop
db2start

If implicit casting for character and graphic constants is disabled, an application that uses weak typing in its SQL will fail to compile for the Db2® product. If enabled, strings and numbers can be compared, assigned, and operated on in a very flexible fashion. Because this data type assignment affects the result types of some SQL statements, it is strongly recommended that this registry variable setting not be toggled for a particular database.

Effects

When implicit casting for character and graphic constants is enabled, the data type of a character or graphic constant depends on the setting of the environment string unit and on the length of the constant:
String Constant Type Environment String Unit Size Data Type
Character CODEUNITS16 or OCTETS ≤ 255 bytes CHAR
CODEUNITS32 ≤ 63 code units
CODEUNITS16 or OCTETS > 255 bytes VARCHAR
CODEUNITS32 > 63 code units
Graphic CODEUNITS16 or OCTETS ≤ 254 bytes GRAPHIC
CODEUNITS32 ≤ 63 code units
CODEUNITS16 or OCTETS > 254 bytes VARGRAPHIC
CODEUNITS32 > 63 code units