SQL Reference

CHAR

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.

Datetime to Character

datetime-expression
An expression that is one of the following three data types

date
The result is the character string representation of the date in the format specified by the second argument. The length of the result is 10. An error occurs if the second argument is specified and is not a valid value (SQLSTATE 42703).

time
The result is the character string representation of the time in the format specified by the second argument. The length of the result is 8. An error occurs if the second argument is specified and is not a valid value (SQLSTATE 42703).

timestamp
The second argument is not applicable and must not be specified. SQLSTATE 42815 The result is the character string representation of the timestamp. The length of the result is 26.

The code page of the string is the code page of the database at the application server.

Character to Character

character-expression
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 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).

Integer to Character

integer-expression
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. It is left justified.

The code page of the string is the code page of the database at the application server.

Decimal to Character

decimal-expression
An expression that returns a value that is a decimal data type. If a different precision and scale is desired, the DECIMAL scalar function can be used first to make the change.

decimal-character
Specifies the single-byte character constant that is used to delimit the decimal digits in the result character string. The character cannot be a digit, plus ('+'), minus ('-') or blank. (SQLSTATE 42815). The default is the period ('.') character

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.

Floating-point to Character

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

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:


[ Top of Page | Previous Page | Next Page ]