Expressions.expr-factor
A single value
Format
[ + | - ]{ Literal |
expr-column-ref
|
expr-primary-constant
|
expr-primary-datetime
|
expr-primary-interval
|
expr-primary-cast
|
( expression
) |
( query-expr
) |
expr-primary-sumfunc
|
Case expression
|
Numeric value function
|
String value function
|
expr-primary-format
|
expr-primary-element
|
expr-primary-opc-time
|
expr-primary-odbc-function
|
expr-primary-odbc-datetime
}
Remarks
An expression factor can be any one of the following:- A constant value literal, such as 12, or 'String', or X'FFFF'. Refer to Literals for more details.
- A column reference, optionally enclosed in double quotes. Refer to expr-column-ref for more details.
- A constant value keyword, such as CURRENT_TIMESTAMP, TRUE, or FALSE. Refer to expr-primary-constant for more details.
- A DATE, TIME, or TIMESTAMP constant value. Refer to expr-primary-datetime for more details.
- An INTERVAL constant value. Refer to expr-primary-interval for more details.
- A conversion from one type to another using the CAST operator. Refer to expr-primary-cast for more details.
- A nested scalar expression using parentheses to control order of evaluation.
- A scalar subquery returning exactly one value. This consists of a query-expr enclosed in parentheses. It is an error if the scalar subquery returns more than 1 row or column.
- An aggregate function, such as COUNT, SUM, AVG, MAX or MIN. Refer to expr-primary-sumfunc for more details.
- An expression returning a value based on a condition, for example CASE, NULLIF. Refer to Case expression for more details.
- A function returning a numeric value, for example SQRT, POSITION. Refer to Numeric value function for more details.
- A function returning a string value, for example SUBSTRING, REPLACE. Refer to String value function for more details.
- An ELEMENT function to return a substring from a string of delimiter separated strings. Refer to expr-primary-element for more details.
- An OPC style time or interval. Refer to expr-primary-opc-time for more details.
- An ODBC function. Refer to expr-primary-odbc-function for more details.
- A D, T, or TS constant value. Refer to expr-primary-odbc-datetime for more details.
Example 1:A simple column reference
CurrentState
Example 2:A more complicated expression
(CurrentValue - 32.0) * 9.0 / 5.0
Example 3:A scalar subquery
(SELECT CurrentValue FROM CDBPoint WHERE FullName = 'My Point')
Example 4:A scalar subquery using an aggregate function
(SELECT MAX(CurrentValue) FROM CPointAlg WHERE FullName LIKE '%Flow') / 100.0