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

sql_cond - rel_exp for Expressions

Syntax

... { {operand1 {=|EQ|<>|NE|>|GT|<|LT|>=|GE|<=|LE} operand2 }
    | {operand  [NOT] BETWEEN operand1 AND operand2}
    | {operand1 [NOT] LIKE operand2 [ESCAPE esc]}
    | {operand  IS [NOT] NULL} } ...

Effect

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

The relational expressions that can be used in expressions are a subset of the relational expressions for statements, but also allow SQL expressions as operands on the right side.

Compares the operand operand1 on the left side with the operand operand2 on the right side. The same applies to relational operators as in a condition for statements. The operands of size comparisons can have the following data types here:
The operand operand2 on the right side can be any SQL expression, which covers columns, literals, host variables, and host expressions. If an operand of the comparison has the null value, the result of this comparison is unknown.
Checks the assignment to an interval. The relational expression functions in the same way as the corresponding condition for statements. The addition NOT is not possible. The operands can have the same data types as for size comparisons. Any SQL expressions can be specified for operand1 and operand2, which covers columns, literals, host variables, and host expressions. If one of the operands has the null value, the result of the check is unknown.
Pattern comparison. The relational expression functions in the same way as the corresponding condition for statements. The addition NOT is not possible. The same applies to the operands as in the condition for statements. The operands must be character-like and only literals and host variables prefixed with an escape character @ can be specified on the right side.
Checks for the null value. The relational expression functions in the same way as the corresponding condition for statements.

The operands on the left side can be any SQL expressions, which covers columns, literals, host variables, and host expressions. With the exception of LIKE, all occurring columns and expressions can have any dictionary types (except for ACCP, DF16_SCL (obsolete), DF34_SCL (obsolete), LCHR, LRAW, PREC, RAWSTRING, and STRING). Literals, host variables, and host expressions can have any ABAP types, except for string and xstring.

It must be possible to compare the data types of the operands of a relational expression. If this is not the case, a statically specified type raises a syntax error and a dynamically specified type raises an exception of the class CX_SY_DYNAMIC_OSQL_SEMANTICS. Unlike in conditions for statements, operands of the types DATS and TIMS are handled like regular flat character-like operands.

If an expression is used for a selection, the client column of a client-specific data source of a query or of the target of a write statement can only be used as an operand in an SQL condition of the expression if automatic client handling is deactivated for the query or write by the addition CLIENT SPECIFIED. This is not possible for filter conditions.

Notes