Converts an ASCII code to its corresponding character.
Syntax
string chr(bigint <ascii>)Parameters
| Parameter | Required | Type | Valid values | Description |
|---|---|---|---|---|
ascii | Yes | BIGINT | 0–128 | The 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.
| Condition | Return value |
|---|---|
ascii is within 0–128 | The character corresponding to the ASCII code |
ascii is null | null |
ascii is outside 0–128 | Error |
ascii is not BIGINT, STRING, DOUBLE, or DECIMAL | Error |
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.
该文章对您有帮助吗?