Code-page determination for string host variables in SQL statements
When you use the integrated Db2® coprocessor (SQL
compiler
option), the code page for processing string host variables in SQL
statements is determined as shown below, in descending order of precedence.
- A host variable that has
USAGE NATIONAL
is always processed by Db2 using CCSID 1200 (Unicode UTF-16). For example:01 hostvariable pic n(10) usage national.
- A host variable that has
USAGE UTF-8
is always processed by Db2 using CCSID 1208 (Unicode UTF-8). For example:01 hostvariable pic u byte-length 10 usage utf-8.
- An alphanumeric host variable that has an explicit
FOR BIT DATA
declaration is set by Db2 to CCSID 66535, which indicates that the variable does not represent encoded characters. For example:EXEC SQL DECLARE hostvariable VARIABLE FOR BIT DATA END-EXEC
- A BLOB, BINARY, or VARBINARY host variable has no CCSID association. These string types do not represent encoded characters.
- A host variable for which you specify an explicit CCSID override in the SQLDA is processed with that CCSID.
- A host variable that you specify in a declaration
with an explicit CCSID is processed with that CCSID. For example:
EXEC SQL DECLARE hostvariable VARIABLE CCSID nnnnn END-EXEC
- An alphanumeric host variable, if the
SQLCCSID
compiler option is in effect, is processed with the CCSID nnnnn from theCODEPAGE
compiler option. - A DBCS host variable, if the
SQLCCSID
option is in effect, is processed with the mapped value mmmmm, which is the pure DBCS CCSID component of the mixed (MBCS) CCSID nnnnn from theCODEPAGE(nnnnn)
compiler option. - An alphanumeric or DBCS host variable, if the
NOSQLCCSID
option is in effect, is processed with the CCSID from the Db2 ENCODING bind option, if specified, or from the APPLICATION ENCODING set in DSNHDECP through the Db2 installation panel DSNTIPF.