Database Reference
In-Depth Information
Brackets, or, as mathematically termed, parentheses, are used to change
the sequence of evaluation within expressions, effectively creating expres-
sions within expressions. The sequence of evaluation is called
precedence
.
See Chapter 7 for details on precedence. Let's try to classify expressions.
14.1
Types of Expressions
Most of expression classification is simple common sense, and so often by
both DBA and programmer alike, is taken for granted.
Basic
. In Oracle SQL, a basic expression is really only a string, a
value, a column, or perhaps a sequence reference within a SELECT
statement list. For example, 'My name is Joe.'
Compounding
. A compound expression is multiple expressions put
together with operators. For example, 10 + 20 or P(1 + r)
n
, a formula
for compound interest calculations.
Lists
. A list of expressions such as (1, 2, x + y, (SELECT * FROM
COUNTRY), 'My name is Joe' ).
Functions
. Any built-in or user-defined function comprises a func-
tional expression. For example, the function POWER(2, 3) will
return 8.
Dates, Times, and Intervals
. Uses various functions and formats to
return a Datetime. Intervals return times between dates.
Scalar Subqueries
. A scalar subquery returns a single value, regard-
less of the number of rows (see Chapter 12).
CURSOR
. A SELECT statement can contain a CURSOR expres-
sion of the form as shown:
SELECT CY.NAME, CURSOR
(SELECT NAME FROM CONTINENT
WHERE CONTINENT_ID = CY.CONTINENT_ID)
FROM COUNTRY CY;
CASE Statements
. A CASE statement can be used as an inline
expression within an SQL query, similar to an IF-THEN-ELSE pro-
gramming construct. The syntax for an inline CASE statement is as
Search WWH ::




Custom Search