THEN/ELSE Expressions Having Mixed Data Types - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

The rules for mixed data appear in the following table.

THEN / ELSE Clause Expressions Rules
Consist of BYTE or VARBYTE data types If the data types of all of the THEN/ELSE expressions are BYTE, the result data type is BYTE. If one or more expressions are VARBYTE, the result data type is VARBYTE.

The result has a length equal to the maximum length of the different byte data types.

Contain a DateTime or Interval data type All of the THEN/ELSE clause expressions must have the same data type.
Contain a FLOAT (approximate numeric) and no character strings The CASE expression returns a FLOAT result.
Inaccuracy is inherent and unavoidable when FLOAT data types are involved.
Are composed only of DECIMAL data The CASE expression returns a DECIMAL result.
A DECIMAL arithmetic result can have up to 38 digits. A result larger than 38 digits produces a numeric overflow error.

For information about how the precision and scale of DECIMAL results are calculated, see Binary Arithmetic Result Data Types.

all are implicitly converted to FLOAT and the CASE expression returns a FLOAT result.

Inaccuracy is inherent and unavoidable when FLOAT data types are involved. Implicit conversion of DECIMAL and INTEGER values to FLOAT values may cause a loss of precision or produce a number that cannot be represented exactly.
Are composed only of mixed DECIMAL, BYTEINT, SMALLINT, INTEGER, and BIGINT data
Are a mix of BYTEINT, SMALLINT, INTEGER, and BIGINT data The resulting type is the largest type of any of the THEN/ELSE clause expressions, where the following list orders the types from largest to smallest:
  • BIGINT
  • INTEGER
  • SMALLINT
  • BYTEINT
Are composed only of numeric and character data The numeric data is converted to CHARACTER with a length as determined by the format associated with the numeric expression. Then, the rules for the result data type for character, length, and character set are applied. For details, see THEN/ELSE Character Type Expressions.
An error is generated if the server character set is GRAPHIC.