What You May Need to Know About Unary and Binary Operators

4-2 Oracle Complex Event Processing CQL Language Reference

4.1.2 What You May Need to Know About Operator Precedence

Precedence is the order in which Oracle CEP evaluates different operators in the same expression. When evaluating an expression containing multiple operators, Oracle CEP evaluates operators with higher precedence before evaluating those with lower precedence. Oracle CEP evaluates operators with equal precedence from left to right within an expression. Table 4–1 lists the levels of precedence among Oracle CQL operators from high to low. Operators listed on the same line have the same precedence. Precedence Example In the following expression, multiplication has a higher precedence than addition, so Oracle first multiplies 2 by 3 and then adds the result to 1. 1+23 You can use parentheses in an expression to override operator precedence. Oracle evaluates expressions inside parentheses before evaluating those outside. Table 4–1 Oracle CQL Operator Precedence Operator Operation +, - as unary operators Identity, negation , Multiplication, division +, - as binary operators, || Addition, subtraction, concatenation Oracle CQL conditions are evaluated after Oracle CQL operators See Chapter 6, Conditions Operators 4-3 Arithmetic Operators Table 4–2 lists arithmetic operators that Oracle CEP supports. You can use an arithmetic operator with one or two arguments to negate, add, subtract, multiply, and divide numeric values. Some of these operators are also used in datetime and interval arithmetic. The arguments to the operator must resolve to numeric datatypes or to any datatype that can be implicitly converted to a numeric datatype. In certain cases, Oracle CEP converts the arguments to the datatype as required by the operation. For example, when an integer and a float are added, the integer argument is converted to a float. The datatype of the resulting expression is a float. For more information, see Implicit Datatype Conversion on page 2-6. Do not use two consecutive minus signs -- in arithmetic expressions to indicate double negation or the subtraction of a negative value. You should separate consecutive minus signs with a space or parentheses. Oracle CEP supports arithmetic operations using numeric literals and using datetime and interval literals. For more information, see: ■ Numeric Literals on page 2-8 ■ Datetime Literals on page 2-10 ■ Interval Literals on page 2-11 Table 4–2 Arithmetic Operators Operator Purpose Example + - When these denote a positive or negative expression, they are unary operators. query id=q1[CDATA[ select from orderitemsstream where quantity = -1 ]]query + - When they add or subtract, they are binary operators. query id=q1[CDATA[ select hire_date from employees where sysdate - hire_date 365 ]]query Multiply, divide. These are binary operators. query id=q1[CDATA[ select hire_date from employees where bonus salary 1.1 ]]query