SSELECT, SSELECTN, SSELECTV

SSELECT, SSELECTN, SSELECTV

Top  Previous  Next

 

The SSELECT statement creates a select list containing all record keys from a file sorted into order.

 

 

Format

 

SSELECT file.var {TO list.no} {modes} {ON ERROR statement(s)}

SSELECTN file.var {TO list.no} {modes} {ON ERROR statement(s)}

SSELECTV file.var {TO list.var} {modes} {ON ERROR statement(s)}

 

where

 

file.varis the file variable associated with an open file.

 

list.nois the select list number of the list to be created. If omitted, select list zero is used.

 

list.varis the select list variable to receive the list. Select list variables can be processed by the READNEXT statement as an alternative to using numbered select lists. If the TO clause is omitted, a default select list variable is used.

 

modesis any of the following optional qualifiers:
DESCENDINGSorts into descending order
NO.CASEPerforms a case insensitive sort
RIGHT.ALIGNEDSorts data in right aligned mode

 

statement(s)are statement(s) to be executed if a fatal error occurs.

 

 

The SSELECT and SSELECTN statements construct a list of record keys in the file open as file.var and store it as an active select list list.no replacing any previously active list. If there are no records in the file, an empty list is created. By default, keys will be stored in left justified ascending order. The optional RIGHT.ALIGNED qualifier causes the list to be sorted as right aligned data. The optional DESCENDING qualifier causes the list to be sorted into descending order. The optional NO.CASE qualifier performs a case insensitive sort.

 

|The SSELECTV statement constructs the list in the same way but stores it in a select list variable which can be processed by a subsequent use of READNEXT. If the TO clause is omitted, the default select list (numbered list 0) is used.

 

The @SELECTED variable is set to the number of records selected.

 

For compatibility with other database products, the action of the SSELECT statement can be changed to produce a select list variable in the same was as SSELECTV. This is achieved by setting the SSELECTV option of the $MODE compiler directive.

 

The optional ON ERROR clause is executed in the event of a fatal error. This covers such situations as disk hardware errors and faults in the internal structure of the file.  The STATUS() function will return a value relating to the cause of the error. If no ON ERROR clause is present, a fatal error will result in an abort.

 

Except where the ON ERROR clause is taken, the STATUS() function will return zero.

 

 

 

Use of a Dynamic Array instead of a File Variable

 

For compatibility with Pick style environments, QM also supports a variation on SSELECT where the file.var is replaced by a dynamic array in which each field becomes an entry in the target select list.

 

 

 

Example

 

SSELECT STAFF TO 7

 

This statement creates a sorted list of the records on the file with file variable STAFF and saves it as active select list 7.