Skip to content

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

Short Reference

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.

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 col of database tables or views. The valid data types are specified in the expressions themselves.
  • Host variables or literals dobj (which cannot have the type string or 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 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. Expressions cannot be specified in all operand positions.

The SQL expression can be used for

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 SELECT statement is sent to the database system. Specifying a host variable from the SELECT list after INTO in a SELECT loop 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.

Continue

sql_exp - sql_elem

sql_exp - sql_arith

sql_exp - sql_arith_func

sql_exp - sql_cast

sql_exp - sql_string

sql_exp - sql_coalesce

sql_exp - sql_case

sql_exp - ( )

Examples of SQL Expressions