Select Lists

Top  Previous  Next

 

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 two types of select list; numbered lists and select list variables.

 

 

Numbered Select Lists

 

The eleven numbered select lists are numbered 0 to 10 and are visible to all parts of a QM session. 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 some other verbs) to be processed.

 

With QM in its default modes, numbered 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.

 

Numbered 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.

 

Numbered 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.

 

Because the numbered select lists are visible to all parts of a QM session, a list created in the command language may be used by a QMBasic program, or vice versa. Named lists saved to the $SAVEDLISTS file can be shared across separate QM processes. They are often used to create a list of records that may be processed many days later. For example, an application might generate a list of overdue accounts and immediately use this list to send letters to the relevant clients. A saved copy of this list might then be used two weeks later to check if the overdue accounts have now been paid.

 

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.

 

 

Select List Variables

 

A QMBasic program can create a select list in a variable by using the SELECTV statement. This can be processed item by item within the application by use of READNEXT in the same way as a numbered list. There is no practical limit to the number of separate select list variables that may exist at one time.

 

 

Pick Compatibility Options

 

To ease migration from Pick style multivalue database products, the PICK.SELECT mode of the $MODE compiler directive can be used to make SELECT produce select list variables instead of numbered lists.