ASCII scalar function

The ASCII function returns the leftmost character of the argument as an integer.

Read syntax diagramSkip visual syntax diagramASCII( string-expression)

The schema is SYSIBM.

The argument can be any built-in character or graphic string data type, except for CLOB or DBCLOB. If the argument is an EBCDIC, Unicode, or graphic string, it is first converted to an SBCS ASCII character string (CCSID 367)1 before the function is executed.

The argument can also be a numeric data type. The numeric argument is implicitly cast to a VARCHAR data type.

The result of the function is a large integer.

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

Example: The following statement returns the ASCII value for the character 'A':
   SET :hv = ASCII('A');
The host variable, :hv, is set to an integer with the value 65.
1 If the conversion does not exist, the ASCII function will return an error, or a substitution character might be returned.