Overflow and Truncation

Some operations can result in data overflow or truncation. Overflow results in an error and can generate Inf. Truncation results in loss of least significant data.

Exact values are truncated only when they are stored in the database by an INSERT or UPDATE statement, and if the target column has smaller scale than the value. TimesTen returns a warning when such truncation occurs. If the value does not fit because of overflow, TimesTen returns the special value Inf and does not insert the specified value.

TimesTen may truncate approximate values during computations, when values are inserted into the database, or when database values are updated. TimesTen returns an error only upon INSERT or UPDATE. When overflow with approximate values occurs, TimesTen returns the special value Inf.

There are several circumstances that can cause overflow:

  • During arithmetic operations, overflow can occur when multiplication results in a number larger than the maximum value allowed in its type. See "Expressions" for more information.

  • When aggregate functions are used, overflow can occur when the sum of several numbers exceeds the maximum allowable value of the result type.

  • During type conversion, overflow can also occur when, for example, a TT_INTEGER value is converted to a TT_SMALLINT value.

Truncation can cause an error or warning for alphanumeric or numeric data types, as follows.

  • For character data, an error occurs if a string is truncated because it is too long for its target type. For NCHAR and NVARCHAR2 types, truncation always occurs on Unicode character boundaries. In the NCHAR data types, a single-byte value (half a Unicode character) has no meaning and is not possible.

  • For numeric data, a warning occurs when any trailing nonzero digit is dropped from the fractional part of a numeric value.