![]() SEL-RANGE |
![]() Virtual Machine |
![]() |
SEL-RANGE is available in non-SQL environments but its effect may be different when used on SQL tables under certain circumstances.
If the table has more than one pseudo-key, K field, in File Maintenance, the rows selected by a particular SEL-RANGE verb differ from those in a non-SQL environment.
In non-SQL environments, all records starting with the one identified by the current values of the component key fields concatenated together and terminating with the one identified by the key-limit parameter, are selected. In SQL environments, only rows where each column is within the range specified by the component key field value and the corresponding substring of the key-limit parameter are selected.
Similar problems arise when an initial key value only is specified, and no other selection criteria is given; the file is read from the initial key value to the end of the file.
Example
Consider a file with two key fields KEY-1 and KEY-2 with values as follows:
Record Number |
KEY-1 |
KEY-2 |
1 |
BBBBBB |
aaaaa |
2 |
BBBBBB |
bbbbb |
3 |
BBBBBB |
eeeee |
4 |
CCCCC |
ccccc |
5 |
CCCCC |
ggggg |
KEY-1 variable currently has the value BBBBB, and KEY-2 the value bbbbb. The following statement is issued:
SEL-RANGE("CCCCCddddd")
Non-SQL environments will select those records with keys between BBBBBbbbbb and CCCCCddddd, that is, records 2, 3 and 4. SQL environments will select only those records with keys starting with a value between BBBBB and CCCCC, and ending with a value between bbbbb and ddddd (records 2 and 4).
Topic ID: 720208