CHR
Purpose
Returns the Latin ASCII character given a numeric code value.
Syntax
where:
Syntax element… |
Specifies… |
TD_SYSFNLIB |
the name of the database where the function is located. |
numeric_expr |
a numeric expression. numeric_expr must be zero or greater. If numeric_expr is greater than 255, an operation of numeric_expr mod 256 is executed to return a value between 0 and 255. If numeric_expr is NULL, the function returns NULL. |
ANSI Compliance
This is a Teradata extension to the ANSI SQL:2011 standard.
Invocation
CHR is an embedded services system function. For information on activating and invoking embedded services functions, see “Embedded Services System Functions” on page 24.
Argument Types and Rules
Expressions passed to this function must have a data type of NUMBER.
You can also pass arguments with data types such as BYTEINT, SMALLINT, INTEGER, or BIGINT that can be converted to NUMBER using the implicit data type conversion rules that apply to UDFs.
Note: The UDF implicit type conversion rules are more restrictive than the implicit type conversion rules normally used by Teradata Database. If an argument cannot be converted to the required data type following the UDF implicit conversion rules, it must be explicitly cast.
For details, see “Compatible Types” in SQL External Routine Programming.
Result Type
The result data type is CHAR(1) CHARACTER SET LATIN.
Example
The following query returns the result 'B'.
SELECT CHR(66);