In DB2® for z/OS® applications,
one CCSID is associated with the source code and one or more CCSIDs
can be associated with the data that your application manipulates.
The CCSID that DB2 associates
with the data is called the application encoding scheme.
About this task
If the CCSID values do not match the actual CCSID of the
data or source, data corruption might occur.
Procedure
To specify a CCSID for your application:
- Use the options as shown in the following table:
Table 1. Options to
set application CCSIDsItem for which you want to specify the CCSID |
Option to use |
Application source code (which includes SQL
statements and literal strings in the SQL statements) |
If you are using the DB2 precompiler, use the CCSID SQL processing option when
you precompile the application. Specify the same CCSID when you compile
the application.
If you are using the DB2 coprocessor, use the language compiler to
set the CCSID. For COBOL, PL/I, and C/C++, use the following instructions: 1.a
The default CCSID for the application source code is the subsystem
EBCDIC CCSID (DECP value SCCSID or MCCSID). DB2 uses this value if you do not use one of
the preceding mechanisms to specify a CCSID.
Restriction: The
compilers for high level host languages do not support Unicode source
code.
|
Application data (values that are passed through
host variables and parameter markers) within SQL statements 1.b |
Use
one or more of the following DB2 mechanisms
to set the CCSID value of the application data, which is called the application
encoding scheme:
The default CCSID for the application data is the subsystem
default application encoding scheme. For static SQL (host variables),
this value is the APPENSCH value from the DECP that is loaded when
you bind your application. For dynamic SQL (parameter markers), this
value is the APPENSCH value from the DECP that is loaded at the time
that the application is executed.
Alternatively,
if you are using the DB2 coprocessor
on a COBOL or PL/I application, you can override the ENCODING bind
option by using the following language compiler options:
|
Application data that is referenced outside
of SQL statements |
Use the rules of the programming language. In
some cases, the CCSID of this data is the same as the CCSID of the
source code. |
Notes: - For older compilers that do not pass a CCSID
value to the DB2 coprocessor,
use the SQL compiler option with the CCSID suboption to specify a
value.
- You can specify different CCSIDs for different
pieces of data in one application. However, if you specify multiple
CCSIDs, do so with caution.
- For DRDA applications,
the ENCODING bind option does not set the CCSID of the data. In a DRDA environment, the CCSIDs are
communicated as part of the protocol.
|
- Optional: If
you want to confirm which CCSID value the DB2 precompiler used, look at the precompiler
listing. If you want to confirm which CCSID value the DB2 coprocessor used, look at the compiler listing. If you need help finding the CCSID values in these listings,
see the example listings in Finding the CCSID values of your data sources.
You can also use these listings to confirm which DECP
module DB2 used. Knowing which
DECP module is useful if you modified a DECP value, such as APPENSCH,
before you compiled or executed your program. You can see which DECP
module and which values DB2 used.