Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  ABAP SQL →  ABAP SQL - Operands and Expressions →  ABAP SQL - SQL Conditions sql_cond 

sql_cond - rel_exp for Statements

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


... { {operand1 {=|EQ|<>|NE|>|GT|<|LT|>=|GE|<=|LE} 
                  {  operand2
                  | {[ALL|ANY|SOME] ( SELECT subquery_clauses [ UNION ...] )} }}
    | {operand [NOT] BETWEEN operand1 AND operand2}
    | {operand1 [NOT] LIKE operand2 [ESCAPE esc]}
    | {operand IS [NOT] NULL}
    | {operand IS [NOT] INITIAL}
    | { EXISTS ( SELECT subquery_clauses [UNION ...] )}
    | {operand [NOT] IN (operand1, operand2 ...)}
    | {operand [NOT] IN ( SELECT subquery_clauses [UNION ...] )}
    | {( operand1, operand2, ... ) IN ( ( operand11, operand21 ... ),
                                        ( operand12, operand22 ... ), ... )}
    | {operand [NOT] IN @range_tab}
    | {(cond_syntax)} } ...

Effect

Relational expression in a condition of an ABAP SQL statement. Logical expressions sql_cond can be formed from the relational expressions shown here for the following conditions:

  • Read accesses
  • Modifying accesses

Possible operanda of a relational expression are elementary SQL operands and SQL expressions. The category of the expression and where it is used determine which operands can be used and where. The following principles apply:

  • No generic SQL expressions can be used on the right side of relational expression.
  • Operands of the type STRING, RAWSTRING, LCHR, LRAW, or GEOM_EWKB cannot be used. One exception is the expression IS [NOT] NULL, which can also evaluate LOBs and geodata types.

A relational expression rel_exp is either true, false, or unknown. The expression is unknown if one of the columns involved in the database contains a null value and is evaluated with another comparison as IS NULL. The result of joins of relational expressions with unknown results is described under AND, OR, NOT.

In an SQL condition of a statement, the client column of a client-specific data source of a query or of the target of a write statement cannot be used as an operand due to implicit client handling. This is checked in full in the strict modes of the syntax check from Release 7.40, SP05.


Notes

  • In comparisons between values determined in the database, it is essential that only operands of the same type and same length are used. This avoids platform-dependent conversion from taking place.

  • If expressions other than the SQL expressions that can be evaluated in the table buffer are used on the left side of a relational expression.

  • If items other than host variables or host expressions are specified on the right side of a relational expression used to identify a single record or a generically buffered area.
In other conditions not used for identifications, columns too can be specified in comparisons or when BETWEEN is used. This applies in cases where neither (numeric) operand has the type DF16_DEC or DF34_DEC, both operands are character-like, or both operands have the type RAW with the same length.

  • A client column can be used as an operand only if implicit client handling is disabled using the obsolete addition CLIENT SPECIFIED for the query or the write statement.

  • When SQL expressions occur on the left side of a relational expression, the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.

  • If dynamic conditions, alias names defined using AS, or joins are used, a client column can be accessed outside the strict modes of the syntax check in WHERE conditions and ON conditions, without implicit client handling being disabled using CLIENT SPECIFIED. In this case, there are two conditions for the client column: the implicit condition of the automatic client handler for the current client and the explicitly specified condition. If the current client is not specified in the explicitly specified condition, no rows are selected.

Continue

sql_cond - Relational Operators

sql_cond - BETWEEN

sql_cond - LIKE

sql_cond - IS NULL

sql_cond - IS INITIAL

sql_cond - EXISTS

sql_cond - IN ( ... )

sql_cond - IN range_tab

sql_cond - (cond_syntax)

sql_cond - subquery_clauses