INTEGER or INT

Click to skip syntax diagram

Numeric to Integer

Read syntax diagramSkip visual syntax diagram>>-+-INTEGER-+--(--numeric-expression--)-----------------------><
   '-INT-----'
 

String to Integer

Read syntax diagramSkip visual syntax diagram>>-+-INTEGER-+--(--string-expression--)------------------------><
   '-INT-----'
 

The INTEGER function returns an integer representation of:

Numeric to Integer

numeric-expression
An expression that returns a numeric value of any built-in numeric data type.

If the argument is a numeric-expression, 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 integers, an error is returned. The fractional part of the argument is truncated.

String to Integer

string-expression
An expression that returns a value that is a character-string or graphic-string representation of a number.

If the argument is a string-expression, 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 a floating-point, integer, or decimal constant. If the whole part of the argument is not within the range of integers, an error is returned. Any fractional part of the argument is truncated.

The result of the function is a large integer. If the argument can be null, the result can be null; if the argument is null, the result is the null value.

Note

Syntax alternatives: The CAST specification should be used for maximal portability. For more information, see CAST specification.

Example