CHR
The CHR function converts a specified ASCII code to a character.
Command format
STRING CHR(BIGINT <ascii>)Parameters
ascii: Required. A BIGINT value that represents an ASCII code. The value must be in the range of 0 to 128.
In data type edition 1.0, if the input is of the STRING, DOUBLE, or DECIMAL type, the function implicitly converts it to the BIGINT type.
Return value
Returns a value of the STRING type. The following rules apply:
If the ascii value is out of the valid range, an error is returned.
If the ascii parameter is not a BIGINT, STRING, DOUBLE, or DECIMAL type, an error is returned.
If the ascii value is NULL, NULL is returned.
Examples
Example 1: Convert the ASCII code
100to a character.-- Returns d. SELECT CHR(100);Example 2: This example shows a command with a NULL input parameter.
--Returns NULL. SELECT CHR(NULL);Example 3: In data type edition 1.0, the input is a STRING value.
SET odps.sql.type.system.odps2=false; -- The input is implicitly converted to the BIGINT type for the operation and returns d. SELECT CHR('100');
Related functions
CHR is a string function. For more information about functions for string searching and format conversion, see String functions.