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
Other versions:
7.31 | 7.40 | 7.54
Syntax
... sql_elem
| sql_arith
| sql_arith_func
| sql_cast
| sql_string
| sql_coalesce
| sql_case ...
Effect
SQL expressions are expressions that can be specified in the following positions of Open SQL statements.
-
As columns specified in the
SELECTlist -
As an argument of aggregate expressions in the
SELECTlist and in theHAVINGclause -
As a grouping criterion after
GROUP BY
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:
-
Suitable columns
colof database tables or views. The valid data types are specified in the expressions themselves. -
Host variables or literals
dobj(which cannot have the typestringorxstring. 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 typeccan 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 typei, which means it always has typei. -
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
-
case distinctions
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.
Notes
- 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 theSELECTlist afterINTOin aSELECTloop 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.