Datetime to Character:
>>-CHAR--(--datetime-expression----+---------------+--)-------->< '-,--+-ISO---+--' +-USA---+ +-EUR---+ +-JIS---+ '-LOCAL-'
Character to Character:
>>-CHAR--(--character-expression----+-------------+--)--------->< '-,--integer--'
Integer to Character:
>>-CHAR--(--integer-expression--)------------------------------><
Decimal to Character:
>>-CHAR--(--decimal-expression----+------------------------+----> '-,--decimal-character---' >----)---------------------------------------------------------><
Floating-point to Character:
>>-CHAR--(--floating-point-expression--)-----------------------><
The schema is SYSIBM. However, the schema for CHAR(floating-point-expression) is SYSFUN.
The CHAR function returns a character-string representation of a:
The result of the function is a fixed-length character string. If the first argument can be null, the result can be null. If the first argument is null, the result is the null value.
The code page of the string is the code page of the database at the application server.
If the length of the character-expression 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 character-expression is greater than the length attribute of the result, truncation is performed. A warning is returned (SQLSTATE 01004) unless the truncated characters were all blanks and the character-expression was not a long string (LONG VARCHAR or CLOB).
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. It is left justified.
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.
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.
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.
The code page of the string is the code page of the database at the application server.
The result is the fixed-length character-string representation of the argument. The result includes a decimal character and p digits, where p is the precision of the decimal-expression with a preceding minus sign if the argument is negative. The length of the result is 2+p, where p is the precision of the decimal-expression. This means that a positive value will always include one trailing blank.
The code page of the string is the code page of the database at the application server.
The result is the fixed-length character-string representation of the argument in the form of a floating-point constant. The length of the result is 24. If the argument is negative, the first character of the result is a minus sign. Otherwise, the first character is a digit. If the argument value is zero, the result is 0E0. Otherwise, the result includes the smallest number of characters that can represent the value of the argument such that the mantissa consists of a single digit other than zero followed by a period and a sequence of digits. If the number of characters in the result is less than 24, then the result is padded on the right with blanks to length 24.
The code page of the string is the code page of the database at the application server.
Examples:
CHAR(PRSTDATE, USA)
Results in the value '12/25/1988'.
CHAR(STARTING, USA)
Results in the value '5:12 PM'.
CHAR(STARTING + :HOUR_DUR, USA)
Results in the value '10:12 PM'.
CHAR(RECEIVED)
Results in the value '1988-12-25-17.12.30.000000'.
SELECT CHAR(LASTNAME,10) FROM EMPLOYEE
For rows having a LASTNAME with a length greater than 10 characters (excluding trailing blanks), a warning that the value is truncated is returned.
SELECT CHAR(EDLEVEL) FROM EMPLOYEE
An EDLEVEL of 18 would be returned as the CHAR(6) value '18 ' (18 followed by four blanks).
CHAR(SALARY, ',')
returns the value '00018357,50 '.
CHAR(20000.25 - SALARY)
returns the value '-0001642.75'.
CHAR(DECIMAL(:SEASONS_TICKETS,7,2))
Results in the character value '10000.00 '.
CHAR(:DOUBLE_NUM)
Results in the character value of '-9.87654321E-33 '. Since the result data type is CHAR(24), there are 9 trailing blanks in the result.