ASCII

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

Read syntax diagram
>>-ASCII(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.

Start of changeThe argument can also be a numeric data type. The numeric argument is implicitly cast to a VARCHAR data type.End of change

Start of changeThe result of the function is a large integer.End of change

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.