CCSID_ENCODING

The CCSID_ENCODING function returns a string value that indicates the encoding scheme of a CCSID that is specified by the argument.

Read syntax diagram
>>-CCSID_ENCODING(expression)----------------------------------><

The schema is SYSIBM.

expression
expression must be an expression that returns a value of a built-in numeric, character, or graphic string data type that is not a LOB. A character string must not have a length attribute greater than 255, and a graphic string must not have a length attribute greater than 127. If expression is a character or graphic string, the string must contain a valid string representation of a number. Leading and trailing blanks are eliminated and the resulting string must conform to the rules for forming a numeric constant.

The function returns a value of ASCII, EBCDIC, UNICODE, or UNKNOWN depending on the CCSID specified by expression.

The result of the function is a fixed-length character string of length 8, which is padded on the right if necessary.

The result can be null; if the argument is null, the result is the null value.

The CCSID of the result is determined from the context in which the function was invoked. For more information, refer to Determining the encoding scheme and CCSID of a string.

Example 1: The following function returns a CCSID with a value for EBCDIC data.
   SELECT CCSID_ENCODING(37) AS CCSID
     FROM SYSIBM.SYSDUMMY1;
Example 2: The following function returns a CCSID with a value for ASCII data.
   SELECT CCSID_ENCODING(850) AS CCSID
     FROM SYSIBM.SYSDUMMY1;
Example 3: The following function returns a CCSID with a value for Unicode data.
   SELECT CCSID_ENCODING(1208) AS CCSID
     FROM SYSIBM.SYSDUMMY1;
Example 4: The following function returns a CCSID with a value of UNKNOWN.
   SELECT CCSID_ENCODING(1) AS CCSID
     FROM SYSIBM.SYSDUMMY1;
Example 5: The following function returns a CCSID with a value for EBCDIC data. The input data is a character string.
   SELECT CCSID_ENCODING('37') AS CCSID 
     FROM SYSIBM.SYSDUMMY1;