Performing Arithmetic Operations
To return the result of an arithmetic expression, use the @COMPUTE
function. The value returned from the function is in the form of a string. Arithmetic expressions can be combinations of the following elements.
-
Numbers
-
The names of columns that contain numbers
-
Functions that return numbers
-
Arithmetic operators:
-
+
(plus) -
-
(minus) -
*
(multiply) -
/
(divide) -
\
(remainder)
-
-
Comparison operators:
-
>
(greater than) -
>=
(greater than or equal) -
<
(less than) -
<=
(less than or equal) -
=
(equal) -
<>
(not equal)
Results that are derived from comparisons can be zero (indicating
FALSE
) or non-zero (indicatingTRUE
). -
-
Parentheses (for grouping results in the expression)
-
The conjunction operators
AND
,OR
. Oracle GoldenGate only evaluates the necessary part of a conjunction expression. Once a statement isFALSE
, the rest of the expression is ignored. This can be valuable when evaluating fields that may be missing or null. For example, if the value ofCOL1
is 25 and the value ofCOL2
is 10, then the following are possible:@COMPUTE ( (COL1 > 0) AND (COL2 < 3) )
returns0
.@COMPUTE ( (COL1 < 0) AND (COL2 < 3) )
returns 0. COL2 < 3 is never evaluated.@COMPUTE ((COL1 + COL2)/5)
returns 7.