Database Reference
In-Depth Information
7.1
Precedence
One factor important with regards to both operators and conditions is that
of precedence. Precedence implies that one operator is executed before
another. Enclosing part of an expression in brackets (parentheses in mathe-
matical jargon) forces that part of the expression to be executed first, start-
ing with the lowest nested or parenthesized level. Let's look at arithmetic
operator precedence to explain this concept.
In this first example expression, the multiplication will execute before
the addition because multiplication has higher precedence than (is executed
before) addition, even though reading from left to right, addition appears
before multiplication.
×
x + y
z
Now let's fix the precedence problem and force addition to execute first
by using parentheses.
×
( x + y )
z
Similarly applying nesting of precedence in the next example, the sub-
traction will be executed first, followed by the addition and finally the mul-
tiplication, regardless of the precedence of the different operators.
×
( x + ( y - p ))
z
That is precedence. Simple, right? Now let's go onto operators.
7.2
Operators
Operators can be divided into several groups, as shown following:
Arithmetic operators allow things like 1 + 1 or 5 * 3, where + and *
are the arithmetic operators.
Logical operators allow merging of multiple expressions.
The concatenation operator is the || goodie allowing concatenation of
strings.
Hierarchical query operators are specialized for use in hierarchical
queries.
Set operators literally do things with sets of rows.
Multiset operators are set operators exclusively for use with nested
table objects.
User-defined operators allow creation of your own operators.
Search WWH ::




Custom Search