Select Lists

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.

 

An active numbered select list can be viewed and edited by use of the SHOW.LIST command.

 

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.

 

The CLEAR.SELECT mode of the OPTION command causes the default select list (list 0) to be cleared on return to the command processor unless the program executed by the command uses the KEEP.SELECT statement to indicate that the list should be retained. This is needed in programs whose role is to generate a select list for processing by subsequent commands.

 

 

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.

 

 

Directory Files

 

When building a select list from a directory file, items that are considered to be hidden files by the operating system are normally included. The DIR.SEL.OMIT.HIDDEN mode of the OPTION command can be enabled to omit the hidden items.

 

 

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.

 

 

Partial Select

 

The QMBasic SELECT, SELECTN and SELECTV statements use an optimised method for processing hashed files such that each group is examined only when the record keys are extracted from the select list. This reduces disk transfers and gives better application performance than constructing the entire list in one operation. It also ensures that very large select lists do not require the entire list to be in memory. This overlapping of processing with record selection means that, if the application writes new records while the select list is being processed, these new records may be seen later in the operation.

 

A similar partial selection mechanism is applied to directory files, reading ids from the underlying operating system directory in burst of no more than the value of the DIRSELSZ configuration parameter.

 

QMClient also provides the ability to perform partial selects.

 

Some operations such as the QMBasic READLIST statement or building a select list in a transaction require that the entire list is available and will force immediate completion of the selection process.