SQL expressions are passed to the database system, executed there, and the result is passed to the application server if requested. The possible operands are:
Suitable columns col of
data sources. The valid data types are specified in the expressions themselves.
Host variables must be prefixed with the escape character @.
Literals are handled strictly according to type. This means that string literals are not allowed and only text field literals of the type c can be used as character literals. Empty
text field literals
cannot be specified. The value of a numeric literal must be in the value range of type i, which means it always has type i.
SQL expressions whose results can be used in accordance with their data type. SQL expressions cannot be specified in all operand positions.
executed. Every expression can be enclosed in parentheses.
The result of an expression is used in the Open-SQL statement in accordance with the operand position, with the data type in nested expressions being specified by the outermost expression.
Host variables and host expressions as operands of expressions are evaluated before the Open SQL statement
is sent to the database system. Specifying a host variable from a SELECT
list after INTO in a SELECT loop does not mean that a different value is used in each loop pass.
When SQL expressions are used, the syntax check is performed in a
strict mode from Release 7.40, SP05, which handles the statement more strictly than the regular syntax check.
If a host expression occurs in an SQL expression, the syntax check is performed in a
strict mode from Release 7.50, which handles the statement more strictly than the regular syntax check.
If required, a column can be specified in an SQL expression using a path expression for associations of a CDS view.
SQL expressions cannot currently be used together with the addition FOR ALL ENTRIES.
If SQL expressions are specified together with aggregate
expressions or with the addition GROUP BY, the syntax check is performed in a
strict mode, which handles the statement more strictly than the regular syntax check.
Syntax example for specifying SQL expressions in different operand positions in a SELECT statement
SELECT FROM sflight FIELDS CONCAT( carrid, connid ) AS key,
MAX( seatsmax - seatsocc ) AS max_free,
MIN( seatsmax - seatsocc ) AS min_free
GROUP BY carrid, connid HAVING SUM( seatsmax - seatsocc ) > 100
ORDER BY key INTO TABLE @DATA(itab).