ENCODING bind option

The ENCODING option specifies the application encoding for all host variables in static statements in a plan or package.

Command option Option values Used with
ENCODING
  • ( ASCII )
  • ( EBCDIC )
  • ( UNICODE ) 1
  • ( ccsid )
Note:
  1. Values other than ENCODING(UNICODE) are not valid for BIND SERVICE commands.
  2. The ENCODING bind option is not valid for REBIND of packages for native SQL procedures, native REST services, or advanced triggers.

EBCDIC is the only valid option for a plan or package that was precompiled prior to DB2® version 7. If you specify ccsid on any plan or package precompiled prior to DB2 version 7, the value of ccsid must match the EBCDIC CCSID specified on the installation panel DSNTIPF (the SYSTEM EBCDIC CCSID). You can specify ASCII, UNICODE, or ccsid, where ccsid is a value other than the SYSTEM EBCDIC CCSID for any plan or package precompiled on DB2 version 7 or later. You might select this option when a data source, such as a terminal emulator, uses a CCSID that is not the same as the SYSTEM EBCDIC CCSID. For example, a user has a terminal emulator with a CCSID of 1047, but the SYSTEM EBCDIC CCSID is 37. In this case, the plan or package being used by that user should be bound with ENCODING (1047).

ENCODING also affects the content of the data that is returned by the SQL statement DESCRIBE. Db2 will return column names, label names, or both (if requested) in the specified application encoding scheme.

Default values for ENCODING

The default package application encoding scheme is not inherited from the plan application encoding option. The default for a package that is bound on a remote Db2 for z/OS® system is the remote server's default application encoding scheme. Similarly, when a plan or package is run on a remote Db2 for z/OS server, the specified ENCODING option is ignored. Instead, the remote server's encoding scheme is used.

The following statements set the value of the host variable and do not require the package to be bound into the plan:

SET CURRENT PACKAGE SET = :HV ,
SET :HV = CURRENT PACKAGE SET ,
SET :HV = CURRENT PACKAGE PATH ,
SET CURRENT PACKAGE PATH = :HV

The host variable uses the system default application encoding scheme, even when the application is bound with the ENCODING (EBCDIC/UNICODE) bind option.

Process Default value
BIND PLAN The system default application encoding scheme that was specified at installation time
BIND PACKAGE The system default application encoding scheme that was specified at installation time
BIND SERVICE UNICODE
REBIND PLAN Existing value
REBIND PACKAGE Existing value

Catalog records for ENCODING

See the ENCODING_CCSID column in SYSPLAN catalog table or SYSPACKAGE catalog table.

The value is set as follows:

  • For a MIXED=NO subsystem, if ENCODING(ASCII) or ENCODING(EBCDIC) is specified, the SBCS CCSID of the encoding scheme is stored in the catalog.
  • For a MIXED=YES subsystem, if ENCODING(ASCII) or ENCODING(EBCDIC) is specified, the mixed CCSID of the encoding scheme is stored in the catalog.
  • If ENCODING(UNICODE) is specified, the mixed CCSID (1208) is stored in the catalog, regardless of the MIXED setting.