If you use the DB2® coprocessor
to prepare a C/C++ application with SQL statements, use the C/C++
compiler to specify the CCSID of the application source. Use DB2 mechanisms to specify the CCSID
of the application data that is manipulated in SQL statements.
Procedure
To specify CCSIDs for C/C++ applications when using the DB2 coprocessor:
- Specify the CCSID for the source code by specifying a LOCALE
value.
Example: The following
JCL EXEC statements for C compile jobs specify a CCSID of 1047. The
first statement specifies a LOCALE for U.S. applications. The second
statement specifies a LOCALE for German applications.
//C EXEC PGM=CCNDRVR,PARM='SQL(),SO,LIST,LOCALE(En_US.IBM-1047)'
//C EXEC PGM=CCNDRVR,PARM='SQL(),SO,LIST,LOCALE(De_CH.IBM-1047)'
Alternatively, you can use other more advanced
methods to specify the CCSID of the source code and any data that
is outside of SQL statements. For more information about those methods,
see the internationalization
information in the C/C++ Programming Guide.
Otherwise,
if you do not specify a CCSID to the C/C++ compiler, the default C/C++
LOCALE of 1047 is passed to the DB2 coprocessor.
Example: The following JCL EXEC statements
for a C compile job does not specify a LOCALE value. Therefore, the
default value of 1047 is passed to the
DB2 coprocessor.
//C EXEC PGM=CCNDRVR,PARM='SQL()'
Recommendation: If
you are using the
DB2 coprocessor
on a C/C++ application, do not specify the SQL compiler option with
the CCSID suboption. If you specify it anyway, and it conflicts with
the LOCALE value,
DB2 issues
a warning. For example, the following EXEC statement for a C compile
job specifies a CCSID value of 1047; the CCSID value 37 is ignored:
//C EXEC PGM=CCNDRVR,PARM='SQL(CCSID(37)),LOCALE(De_CH.IBM-1047)'
- Specify the CCSID for data within SQL statements by specifying
a value for the ENCODING
bind option bind option or accept the subsystem default application
encoding scheme (the DECP value APPENSCH). This value
is used as the CCSID for the application data.
- To override the CCSID for particular host variables or
parameter markers, use the DECLARE VARIABLE statement or CURRENT APPLICATION
ENCODING SCHEME special register. If you need help using either of
these techniques, following the instructions in Specifying a CCSID for your application.
If you specify different CCSIDs for different pieces of data,
do so with caution.