Precedence is the order in which Sybase CEP Engine evaluates different operators in the same expression.
When evaluating an expression containing multiple operators, Sybase CEP Engine evaluates operators with higher precedence before evaluating those with lower precedence. Sybase CEP Engine evaluates operators with equal precedence from left to right within an expression.
The following table lists the order of precedence among CCL operators from high to low. Operators listed on the same line have the same precedence.
Operator |
Operation |
---|---|
+, - (as unary operators) |
Unary plus, negation |
^ |
Exponent |
*, /, mod |
Multiplication, division, modulo |
+, - (as binary operators), || |
Addition, subtraction, concatenation |
=, !=, <>, <, >, <=, >= |
Comparison |
LIKE, REGEXP_LIKE, IN, IS NULL, IS NOT NULL |
Like |
NOT |
Logical negation |
AND |
Conjunction |
OR, XOR |
Disjunction |
Note that the ^ operator is right associative. Thus a ^ b ^ c = a ^ (b ^ c), not (a ^ b) ^ c.
In the following expression, multiplication has a higher precedence than addition, so Sybase CEP Engine first multiplies 30 by 5 and then adds the result to 10, so that the computed expression is 160:
10+30*5
Use parentheses in an expression to override operator precedence. Sybase CEP Engine evaluates expressions inside parentheses before evaluating those outside. In the following expression, the computed value is 200 because the sum of 10 and 30 is computed first.
(10+30)*5