Previous Topic: Representation of Date/Time ValuesNext Topic: Null Values


Comparison, Assignment, Arithmetic, and Concatenation Operations

The data type, length, and magnitude of a value determine how CA IDMS handles the value during comparison, assignment, arithmetic, and concatenation operations. The same factors also affect the outcome of these operations.

For example:

Binary Values

Comparison

Binary values can be compared to the following:

Assignment

Binary values can be assigned to the following:

Arithmetic

You cannot use binary values in arithmetic operations.

Concatenation

Binary values can be concatenated with other binary values and with character values. For the purposes of concatenation, binary values are treated as character values, and the result of a concatenation operation is a character value.

Character Values

Comparison

Character values can be compared to the following:

Assignment

Character values can be assigned to the following:

Arithmetic

You cannot use character values in arithmetic operations.

Concatenation

Character values can be concatenated with other character values.

If one value in the concatenation:

A character value and a binary value can be concatenated. The binary value is treated as a character value for the purpose of concatenation.

Date/time Values

Comparison

Date/time values can be compared to:

Assignment

Date/time values can be assigned to the following:

Arithmetic

You can use date/time values only in addition and subtraction. Special rules govern date/time arithmetic.

Note: For information about date/time arithmetic, see Date/time Arithmetic.

Concatenation

You can concatenate a date value and a time value using the TIMESTAMP function.

Note: For more information about the TIMESTAMP function, see CA IDMS Scalar Functions.

Graphics Character Values

Comparison

Graphics character values can be compared to other graphics character values. When comparing graphics character values of different lengths, CA IDMS pads the shorter value with double-byte blank characters on the right to make the lengths equal.

Assignment

Graphics character values can be assigned to graphics character constructs (for example, to a column with a data type of GRAPHIC or VARGRAPHIC): If the graphics character value is:

Arithmetic

You cannot use graphics character values in arithmetic operations.

Concatenation

Graphics character values can be concatenated with other graphics character values.

If one of the values has a data type of VARGRAPHIC, the result has a data type of VARGRAPHIC. Otherwise, the result has a data type of GRAPHIC.

If one value in the concatenation is null, the result is null. Otherwise, the length of the result is the sum of the lengths of the two values that are concatenated. The length of the result cannot exceed 32,760.

Usage

The use of graphics data requires the installation of CA IDMS DBCS.

Numeric Values

Comparison

Numeric values can be compared only to other numeric values.

Assignment

Numeric values can be assigned only to numeric constructs (for example, to a column with a data type of DECIMAL).

When assigning a value of one numeric data type to a construct of a different numeric data type, CA IDMS converts the value to the data type of the construct:

Arithmetic

You can use values of all numeric data types (both approximate and exact) in arithmetic operations. Additionally, a single arithmetic expression can include values of more than one numeric data type.

Data Type Conversion for Comparison and Arithmetic

When a comparison or arithmetic operation involves two values of different numeric data types, CA IDMS determines which data type has higher precedence. CA IDMS then converts both values to a common data type based on the data type of higher precedence:

 

Data type of highest precedence

Common data type for conversion

Highest

 

DOUBLE PRECISION

FLOAT

REAL

DOUBLE PRECISION

 

DECIMAL

NUMERIC

DECIMAL

 

LONGINT

LONGINT

Lowest

INTEGER

SMALLINT

INTEGER

Precision of the Result

The precision of the result of comparison or arithmetic operation when a conversion involves a decimal data type is:

Examples of Data Type Conversion

For example, to add a NUMERIC value to an INTEGER value, CA IDMS converts both values to DECIMAL. To compare a FLOAT value to a REAL value, CA IDMS converts both values to DOUBLE PRECISION.