The SSELECT command creates a temporary select-list of sorted file items to be processed by the next TCL or INFO/ACCESS statement, or by other processors such as the Editor, mvBASIC, or PROC. Creating a select-list is a useful way to define and operate on a subset of items in a database.
Format
SSELECT [DICT] filename [item-list] [selection] [sort-keys] [output] |
Parameter(s)
DICT |
Specifies the file dictionary. |
|
filename |
Name of the file. |
|
item-list |
List of individual item-IDs that you want to select or compare against specified criteria. Enclose each item-ID in single quotes. If you do not specify an item-list, the SSELECT command selects all items in filename. |
|
selection |
Specifies one or more conditions that an item must meet to be included in the select-list. For a complete description of selection expression syntax, see the LIST Command. |
|
sort-keys |
Specifies which attributes to sort and whether to sort them in ascending or descending order. You can use the following modifiers with sort-keys: |
|
BY |
Sorts items in ascending order by the specified attribute. |
|
BY-DSND |
Sorts items in descending order by the specified attribute. |
|
BY-EXP |
Sorts a MultiValued attribute in ascending order and produces a separate line for each value. |
|
BY-EXP-DSND |
Sorts a MultiValued attribute in descending order and produces a separate line for each value. |
|
If more than one sort-key is specified in a SSAMPLE command line, the system sorts these attributes from left to right (the leftmost sort-key is the most significant). |
||
output |
Name of an attribute whose values are to be selected. Each value becomes a separate item-ID in the select-list. |
Description
The SSELECT command creates a temporary select-list containing sorted item-IDs of the items specified in the item-list or the selection criteria. The items referenced by the select-list are processed by the next command you execute. For instance, before invoking the Editor you might create a select-list as a way of specifying which items you want to edit.
CAUTION |
Only the statement immediately following the SSELECT statement has access to the select-list. In other words, you must use the select-list immediately, or you will lose it! |
To permanently save the select-list, use the SAVE-LIST command. Once a select-list is saved, you can retrieve it at any time with the GET-LIST command.
A select-list can reference data in any file, not just the file specified in the original SSELECT statement. If two files have similar items with the same item-IDs, you can create a select-list from one file, then use it to operate on items from the other file.
Creating a Sorted Select-list
The following example illustrates how to create a select-list from one file and use it to access data in another file.
Assume that a file called CUSTOMER.OVERDUE contains item-IDs of customers with overdue accounts. The attribute DATE.DUE contains the payment due date. The following example creates a select-list of customers from the attribute, then displays a report of the customers’ names and addresses:
>SSELECT CUSTOMERS.OVERDUE BY DATE.DUE 4 ITEMS SELECTED. >LIST CUSTOMERS LAST-NAME FIRST-NAME STREET CITY STATE . . . |
The report does not include the payment due date because DATE.DUE was not specified with the LIST command. The items appear in sorted sequence, however, with the customers that have the earliest payment due dates at the beginning of the report.