Thursday, November 22, 2007

Selection Tables in the WHERE Clause

The WHERE clause is an addition to Open SQL statements SELECT, UPDATE, and DELETE,
and is used to restrict the values read during database accesses [Page 1037].
To use a selection table in the WHERE clause, you write:

......... WHERE IN .

is the name of a database column, and is the selection table that is assigned to this

field. The relevant Open SQL statement accesses only those rows of the database table, where
the contents of field meet the selection criteria stored in .

REPORT DEMO.
DATA WA_CARRID TYPE SPFLI-CARRID.
SELECT-OPTIONS AIRLINE FOR WA_CARRID.
SELECT CARRID FROM SPFLI INTO WA_CARRID WHERE CARRID IN
AIRLINE.
WRITE WA_CARRID.
ENDSELECT.
Selection table AIRLINE is linked to the CARRID column of database table SPFLI.
The WHERE clause of the SELECT statement checks if the contents of the CARRID
column meet the selection criteria stored in AIRLINE.
If the selection table is filled as follows:
SIGN OPTION LOW HIGH
I BT DL UA
E EQ L H
Then the database rows for all airlines between DL and UA except LH are read.

No comments:

Blog Archive