Specifying CCSIDs for C/C++ applications when using the Db2 coprocessor

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:

  1. Specify the CCSID for the source code by specifying a LOCALE value.
    For 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.

    For examples, 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)'
    
  2. Optional: Start of changeYou can specify different encoding schemes for application data that the program processes. You can use one or more of the following Db2 approaches to specify CCSID values for the application data1, which is called the application encoding scheme:
    End of change
1 Use caution if you specify different CCSIDs for different pieces of data, which can result in character conversion.
2 For DRDA applications, the ENCODING bind option does not set the CCSID of the data, and CCSIDs are communicated as part of the protocol.