INTEGER or INT
The INTEGER function returns an integer representation of either a number or a character string or graphic string representation of an integer.
Numeric to Integer:
>>-+-INTEGER-+-(numeric-expression)---------------------------->< '-INT-----'
String to Integer:
>>-+-INTEGER-+-(string-expression)----------------------------->< '-INT-----'
The schema is SYSIBM.
- Numeric to Integer
- numeric-expression
- An expression that returns a value of any built-in numeric data
type.
The result is the same number that would occur if the argument were assigned to a large integer column or variable. If the whole part of the argument is not within the range of large integers, an error occurs. The fractional part of the argument is truncated.
- String to Integer
- string-expression
- An expression that returns a value of a character
or graphic string (except a CLOB or DBCLOB) with a length attribute
that is not greater than 255 bytes. The string must contain a valid
string representation of a number.
The result is the same number that would result from CAST(string-expression AS INTEGER). Leading and trailing blanks are eliminated and the resulting string must conform to the rules for forming an integer constant. If the whole part of the argument is not within the range of large integers, an error is returned.
The result of the function is a large integer.
The result can be null; if the argument is null, the result is the null value.
SELECT INTEGER(AVG(SALARY)+.5)
FROM DSN8A10.EMP
WHERE WORKDEPT = 'A00';
SELECT INTEGER(EMPNO)
FROM DSN8A10.EMP;