ABAP Keyword Documentation → ABAP - Reference → Processing External Data → ABAP Database Accesses → Open SQL → Open SQL - Read Accesses → SELECT → SELECT - result → SELECT - select_list → SELECT - col_spec
SELECT - sql_exp
7.31 | 7.40 | 7.54
| sql_case ...
SQL expressions are expressions that can be specified in the following positions of Open SQL statements.
As columns specified in the
As an argument of aggregate expressions in the
SELECTlist and in the
As a grouping criterion after
SQL expressions are passed to the database system, executed there, and the result is passed to the application server if necessary. The possible operands are:
colof database tables or views. The valid data types are specified in the expressions themselves.
Host variables or literals
dobj(which cannot have the type
xstring. 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
ccan 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
SQL expressions whose results can be used in accordance with their data type. Expressions cannot be specified in all operand positions.
The SQL expression can be used for
- assignments of columns, host variables, or literals
- arithmetic calculations
- calls of arithmetic functions
- type modifications
- chainings of character strings
- replacing null values
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.
- SQL expressions cannot be used in obsolete non-Unicode programs and not if the program attribute fixed point arithmetic is switched off.
Host variables as operands of expressions are evaluated before the
SELECTstatement is sent to the database system. Specifying a host variable from the
SELECTloop does not mean that a different value is used in each loop pass.
- No aggregate expressions as operands of SQL expressions can currently be specified. SQL expressions can, however, be arguments of aggregate functions.
- When SQL expressions are used, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.
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.