The CHAR function returns a fixed-length character string representation.

The representations are:

- A character string, if the first argument is any type of character string.
- A datetime value, if the first argument is a date, time, or timestamp.
- A decimal number, if the first argument is a decimal number.
- A double-precision floating-point number, if the first argument is a DOUBLE or REAL.
- An integer number, if the first argument is a SMALLINT, INTEGER, or BIGINT.

CHAR (characterExpression[ ,integer] )

*characterExpression*- An expression that returns a value that is CHAR, VARCHAR, LONG VARCHAR, or CLOB data type.
*integer*- The length attribute for the resulting fixed length character string. The value must be between 0 and 254.

If the length of the *characterExpression* is less than
the length attribute of the result, the result is padded with blanks up to
the length of the result. If the length of the *characterExpression* is greater
than the length attribute of the result, truncation is performed. A warning
is returned unless the truncated characters were all blanks and the
*characterExpression* was not a long string (LONG VARCHAR or CLOB).

CHAR (integerExpression)

*integerExpression*- An expression that returns a value that is an integer data type (either SMALLINT, INTEGER, or BIGINT).

The result is the character string representation of the
argument in the form of an SQL integer constant. The result consists of *n*
characters that are the significant digits that represent the value of the
argument with a preceding minus sign if the argument is negative. The result is
left justified.

- If the first argument is a SMALLINT: The length of the result is 6. If the number of characters in the result is less than 6, then the result is padded on the right with blanks to length 6.
- If the first argument is an INTEGER: The length of the result is 11. If the number of characters in the result is less than 11, then the result is padded on the right with blanks to length 11.
- If the first argument is a BIGINT: The length of the result is 20. If the number of characters in the result is less than 20, then the result is padded on the right with blanks to length 20.

CHAR (datetimeExpression)

*datetimeExpression*- An expression that is one of the following three data types:
- DATE: The result is the character representation of the date. The length of the result is 10.
- TIME: The result is the character representation of the time. The length of the result is 8.
- TIMESTAMP: The result is the character string representation of the timestamp. The length of the result is 26.

CHAR (decimalExpression)

*decimalExpression*- An expression that returns a value that is a decimal data type.

CHAR (floatingPointExpression)

*floatingPointExpression*- An expression that returns a value that is a floating-point data type (DOUBLE or REAL).

Use the CHAR function to return the values for EDLEVEL (defined
as smallint) as a fixed length character string:

An EDLEVEL of 18 would be returned as the CHAR(6) value '18 ' (18 followed by four blanks).SELECT CHAR(EDLEVEL) FROM EMPLOYEE