Expressions
An SQL value expression, referred to as an expression, can evaluate to a value with one of these:
"Character Value Expressions" (page 255)
"Datetime Value Expressions" (page 257)
"Interval Value Expressions" (page 261)
"Numeric Value Expressions" (page 265)
The data type of an expression is the data type of the value of the expression.
A value expression can be a character string literal, a numeric literal, a dynamic parameter, or a
column name that specifies the value of the column in a row of a table. A value expression can
also include functions and scalar subqueries.
Character Value Expressions
The operands of a character value expression—referred to as character primaries—can be
combined with the concatenation operator (||). The data type of a character primary is character
string.
character-expression is:
character-primary
| character-expression || character-primary
character-primary is:
character-string-literal
| column-reference
| character-type-host-variable
| dynamic parameter
| character-value-function
| aggregate-function
| sequence-function
| scalar-subquery
| CASE-expression
| CAST-expression
| (character-expression)
| OLAP-window-function
Character (or string) value expressions are built from operands that can be:
•
Character string literals
•
Character string functions
•
Column references with character values
•
Dynamic parameters
•
Aggregate functions, sequence functions, scalar subqueries, CASE expressions, or CAST
expressions that return character values
•
OLAP window functions
Operands can be combined with the concatenation
operator (||). Example: 'HOUSTON,' ||' TEXAS'
Operands can be combined in specific ways with
arithmetic operators. Example: CURRENT_DATE +
INTERVAL '1' DAY
Operands can be combined in specific ways with addition
and subtraction operators. Example: INTERVAL '2'
YEAR - INTERVAL '3' MONTH
Operands can be combined in specific ways with
arithmetic operators. Example: SALARY * 1.10
Expressions
255