The wchar_t and sqldbchar data types for graphic data in C and C++ embedded SQL applications

The size and encoding of Db2® graphic data is constant from one operating system to another for a particular code page. However, the size and internal format of the ANSI C or C++ wchar_t data type depend on which compiler and operating system you use.

The sqldbchar data type is defined by Db2 to be 2 bytes in size, and is intended to be a portable way of manipulating DBCS and UCS-2 data in the same format in which it is stored in the database.

You can define all Db2 C graphic host variable types with either the wchar_t or sqldbchar data type. You must use the wchar_t data type if you build your application with the WCHARTYPE CONVERT precompile option.

If you build your application with the WCHARTYPE NOCONVERT precompile option, you can use the sqldbchar data type for maximum portability between different Db2 client and server environments. You can use the wchar_t data type with the WCHARTYPE NOCONVERT option, but only on environments where the wchar_t data type is defined as 2 bytes in length.

If you incorrectly use either a wchar_t or sqldbchar data type in host variable declarations, an error can be returned during the precompile process.