Select Lists |
![]() ![]() ![]() |
Select lists are lists of things to be processed, usually record keys from a file. The list may contain all record keys or only those where the key or record data meets some specified criteria. Using select lists simplifies and speeds up many data processing operations using commands or within QMBasic programs. There are 11 select lists numbered 0 to 10. List 0 is referred to as the default select list and is used by some verbs such as COPY to determine the records (or files for other verbs) to be processed.
Select lists are created by the SELECT or SSELECT query processor commands. The SELECT command builds a list of keys of records meeting the specified criteria but with no apparent ordering to the list. The SSELECT command is similar but the list is in order of record key value. The SELECT command is faster both during generation of the list and subsequent processing of records as its order reflects the placement of records within the file.
Select lists can also be created by the QMBasic SELECT statement. This statement builds a list of all records in the file and provides no means of including or excluding records by selection criteria. Programs can then read keys sequentially from the list using the READNEXT statement.
Select lists may also be saved to records in the $SAVEDLISTS file using SAVE.LIST and later restored using GET.LIST. Lists that have been written to other files by QMBasic programs may be restored using FORM.LIST. The EDIT.LIST command allows editing of select lists. Saved select lists may be copied using COPY.LIST, deleted using DELETE.LIST or merged using MERGE.LIST.
A select list represents a "snapshot" of the file at the time when it was generated. Adding, deleting or modifying records will not affect the select list. Thus, if a file may be modified by another process between generation of the select list and retrieval of records for processing, the program must allow for records that have been deleted or no longer meet the selection criteria.
A special type of select list, an exploded list, is constructed using the BY.EXP or BY.EXP.DSND keywords of the query processor. In an exploded select list, the multivalued field from which it was created generates a separate entry for each value or subvalue. The internal representation of this list includes information to identify the value and subvalue positions of the corresponding data element. This can be retrieved by the QMBasic READNEXT statement and is used automatically by some operations within the query processor. |