This relational expression compares the content of the operand operand1 (in
accordance with the relational operator operator) with the the content of the operand operand2 or with the result of a
scalar subquery.
The following can be specified for operand1 on the right side:
The following can be specified for operand2 on the right side:
A literal, a host variable, or a
host expression. The content of the operands must match the data type of operand1 in accordance with the rules for
lossless assignments. This is checked by the
strict modes of the syntax check from Release
7.40, SP08 and can raise an exception. The name of a host variable should be prefixed with the escape character @.
A column of a
data source of a
query or the target of a
write specified after FROM. Here, the column must be specified as data_source~comp or tabalias~comp using the
column selector. It must be possible to
compare the data types on the left side and right side with each other.
Comparisons between columns or between SQL expressions or aggregate expressions and columns are
performed in full on the database. No type conversions are made in ABAP beforehand. If the data types
or lengths on the left and right side do not match, the resulting behavior depends entirely on the conversion
rules of the database (however, fewer conversions are generally possible here than in ABAP). The platform-dependent behavior can produce different results or even SQL errors on individual platforms.
The decimal places are respected in comparisons between numeric types.
In greater than/less than comparisons with character-like types, the result can depend on the code page used by the database system.
Trailing blanks are usually ignored in comparisons between character-like types.
In the case of columns that contain nothing but a blank character, it is the platform that determines how this blank is saved:
In the SAP HANA database and in MaxDB a single blank is saved as an empty string and not as specified by the code page in question.
In all other database and in table buffering, a single blank is saved in accordance with the code page.
This means that the behavior produced when a value of this type is selected using size comparisons is
determined by the platform and by buffering. More specifically, a single blank in the SAP HANA database and in MaxDB is not found in the interval of all possible characters.
Notes
The obsolete forms ><,
=<, and => of relational operators may still appear outside of classes.
Size comparisons for character-like operands should be avoided to prevent platform-dependent behavior. An exception here are simple cases, such as operands that contain only digits.
Example
Gets flights with a seat occupancy that is less than the entered value.
DATA seatsocc TYPE sflight-seatsocc. cl_demo_input=>request( CHANGING field = seatsocc ).
SELECT carrid, connid, fldate
FROM sflight WHERE seatsocc < @seatsocc INTO TABLE @DATA(sflight_tab).
Example
Gets overbooked flights.
SELECT carrid, connid, fldate FROM sflight WHERE seatsocc > sflight~seatsmax
INTO TABLE @DATA(sflight_tab).