Operators

You can specify values by using arithmetic operations on numbers, comparisons, and logical operations. These operations are specified by an infix operator (which is an operator between operands), or by a prefix operator (which is an operator in front of operands).

Arithmetic operations

You can apply the prefix operator plus (+) or minus (-) to any numeric value. See the following example:
-DOWN_TIME	
+40	
-23.456	
-1E8
The result is of the same type as the operand. The prefix plus (+) does not change its operand. The prefix minus (-) reverses the sign of its operand.
You can apply the infix operator plus (+), minus (-), multiply (*), and divide (/) between any pair of numeric values. See the following example:
A+B	
N_DATASETS-5	
COUNT*1E-6	
RESP_TIME/60
The result depends on the operand types:
  • If both operands are integers, the result is an integer. The operation is performed using integer arithmetic. The division is performed so that the remainder has the same sign as the dividend.
  • If both operands are floating-point numbers, the result is a floating-point number. The operation is performed using long floating-point operations of S/390®.
  • If one of the operands is an integer and the other a floating-point number, the integer is converted to a floating-point number. The operation is then performed on the result of the conversion, using floating-point arithmetic. The result is a floating-point number.

The result of dividing an integer by another integer is also an integer. For example, if RESP_TIME is an integer less than 60, the result of RESP_TIME/60 is 0. If you want the exact result, write RESP_TIME/60.0 instead, which makes the operand on the right the floating-point number 60.0. Then the operand on the left, which is RESP_TIME, is converted to a floating-point number, making the result a floating-point number.

For all operators, the result is null if any of the operands is null. If the result is an integer, the result must be within the range of integers. If the result is a floating-point number, the result must be within the range of floating-point numbers. The operand on the right of a divide operator must not be 0.

Comparisons

You can compare two values by using the infix operator equal (=), not equal (<>), greater than (>), less than (<), greater than or equal (>=), less than or equal (<=). The result is a value of true or false. If one of the values in the comparison is null, the result is unknown. See the following example:
A>10	
JOB_NAME<'ABC'	
DATE<>'1993.04-15'
Only the following types of comparisons are allowed:
  • Numbers with numbers
  • Character strings with character strings or date and time values
  • Date and time values with character strings or date and time values of the same type

Numbers are compared by their algebraic values. If both numbers are floating-point numbers, they are compared by using long floating-point operation of S/390. Two floating-point numbers are considered equal only if their normalized forms have identical bit configurations.

If one of the numbers is an integer number and the other a floating-point number, the integer number is converted to a floating-point number. The comparison is then performed with the result of the conversion.

Character strings are compared byte by byte, left to right. If the strings are different in length, the comparison is made with a temporary copy of the shorter string that is extended on the right with the necessary number of blanks so that it has the same length as the other string..

Two strings are equal if they are both empty or if all corresponding bytes are equal. Otherwise, their relation is determined by the comparison of the first unequal pair of bytes.

When a character string is compared with a date and time value, it must be a valid date and time string of the corresponding kind. The string is converted to a date and time value and the comparison is performed on the result.

All comparisons of date and time values are chronological. The value that represents the later point of time is considered to be greater.

Because the hour part may range from 0 to 24, certain pairs of different timestamps represent the same time. When such timestamps are compared, the one with a greater date part is considered greater. For example, the result of this comparison is true:
TIMESTAMP('1985-02-23-00.00.00.000000')>TIMESTAMP('1985-02-22-24.00.00.000000')
However, the INTERVAL calculates the interval between these timestamps as 10.

Logical operations

You can apply the prefix operator NOT to any value of true or false. The following table shows the result that is defined for operand p:
Table 1. Logical operation NOT
p NOT p
True False
False True
Unknown Unknown
You can apply the infix operator AND and OR to any pair values of true or false. The following table shows the result that is defined for operand p and q:
Table 2. Logical operations AND and OR
p q p AND q p OR q
True True True True
True False False True
True Unknown Unknown True
False True False True
False False False False
False Unknown False Unknown
Unknown True Unknown True
Unknown False False Unknown
Unknown Unknown Unknown Unknown