CHR

更新时间:
复制 MD 格式

Converts an ASCII code to its corresponding character.

Syntax

string chr(bigint <ascii>)

Parameters

ParameterRequiredTypeValid valuesDescription
asciiYesBIGINT0–128The ASCII code to convert. STRING, DOUBLE, and DECIMAL inputs are implicitly converted to BIGINT before the function runs.

Return value

Returns a value of the STRING type.

ConditionReturn value
ascii is within 0–128The character corresponding to the ASCII code
ascii is nullnull
ascii is outside 0–128Error
ascii is not BIGINT, STRING, DOUBLE, or DECIMALError

Examples

Example 1: Convert the ASCII code 100 to a character.

-- Returns: d
select chr(100);

Example 2: Pass a null value.

-- Returns: null
select chr(null);

Example 3: Pass a STRING value. The input is implicitly converted to BIGINT before calculation.

-- Returns: d
select chr('100');

Related functions

CHR is a string function. For more information about string search and conversion functions, see String functions.