DB2 Version 10.1 for Linux, UNIX, and Windows

Character and graphic constant handling

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

Enablement

To enable character and graphic constant handling support, set the DB2_COMPATIBILITY_VECTOR registry variable to hexadecimal value 0x100 (bit position 9), and then stop and restart the instance to have the new setting take effect.
db2set DB2_COMPATIBILITY_VECTOR=100
db2stop
db2start
To take full advantage of the DB2® compatibility features for Oracle applications, the recommended setting for the DB2_COMPATIBILITY_VECTOR is ORA, which sets all of the compatibility bits.

Prior to character or graphic constant support, an application that used weak typing in its SQL would have failed to compile against the DB2 product. With implicit casting, strings and numbers can be compared, assigned, and operated on in a very flexible fashion. After character or graphic constant support is enabled, character or graphic string constants whose length is less than or equal to 254 bytes have a data type of CHAR or GRAPHIC, respectively. Character or graphic string constants whose length is greater than 254 bytes have a data type of VARCHAR or VARGRAPHIC, respectively. Because this data type assignment can change the result types of some SQL statements, it is strongly recommended that this registry variable setting for a database not be toggled.

Effects

After you enable the support, constants are handled as follows:
  • Character string constants whose lengths are less than or equal to 254 bytes have a data type of CHAR.
  • Graphic string constants whose lengths are less than or equal to 254 bytes have a data type of GRAPHIC.
  • Character string constants whose lengths are greater than 254 bytes have a data type of VARCHAR.
  • Graphic string constants whose lengths are greater than 254 bytes have a data type of VARGRAPHIC.

Because these data type assignments can change the result types of some SQL statements, do not toggle this registry variable setting.