Language Reference Guide : 2. Language Elements : Expressions : Expressions in SQL Statements
 
Share this page                  
Expressions in SQL Statements
When using expressions in SQL statements in OpenROAD, the operands of the functions and operators (or the entire expression) may be literals or database column names. In contexts where correlation names are defined (for example, with the select statement), a column name may be preceded by a correlation name (separated from the column name by a period).
You can replace any literal with a named constant or simple variable name (or a reference to a simple variable that is an attribute of a reference variable or an attribute of a row of an array variable) preceded by a colon. However, the field function is not allowed in database statements, nor are procedure or method invocations. SQL function and operators are allowed (they are evaluated by the database).
Expressions are composed of various operators and operands that evaluate to a single value or a set of values. Some expressions do not use operators; for example, a column name is an expression. Expressions are used in many contexts, such as specifying values to be retrieved (in a SELECT clause) or compared (in a WHERE clause). For example:
SELECT empname, empage FROM employee
WHERE salary > 75000
In the preceding example, empname and empage are expressions representing the column values to be retrieved, salary is an expression representing a column value to be compared, and 75000 is an integer literal expression.
Expressions that contain aggregate functions can appear only in SELECT and HAVING clauses, and aggregate functions cannot be nested.
An expression can be enclosed in parentheses without affecting its value.