SELECT and SSELECT

SELECT and SSELECT

Top  Previous  Next

 

The SELECT and SSELECT verbs build a select list containing the keys of records meeting specified criteria. SSELECT is equivalent to SELECT with a final sort by record id.

 

SELECT {DICT} file.name

{USING {DICT} file.name}

{selection.clause}

{sort.clause}

{record.id...}

{FROM select.list.no}

{SAVING {UNIQUE} {MULTI.VALUE} field.name {NO.NULLS}}

{TO select.list.no}

 

 

SSELECT {DICT} file.name

{USING {DICT} file.name}

{selection.clause}

{sort.clause}

{record.id...}

{FROM select.list.no}

{SAVING {UNIQUE} {MULTI.VALUE} field.name {NO.NULLS}}

{TO select.list.no}

 

 

Example

 

SELECT VOC WITH F1 LIKE F...

 

This command builds a select list containing the ids of VOC records with field one starting with an upper case F. Such a list corresponds to all files defined by the VOC.

 

The list of record ids (or other data when using SAVING) is stored in select list 0 unless the TO clause is used to specify a different list.

 

 

Chained Selects

 

For compatibility with other multivalue products, if the CHAINED.SELECT mode of the OPTION command is active, a GET.LIST, SELECT, SSELECT or QSELECT that returns a list with at least one entry will examine the DATA queue. If there is anything in this queue, the first queue item is read and executed as a command. This allows applications to create sequences of commands that will be executed if the SELECT is successful. For example, a QMBasic program might contain

DATA 'LIST STOCK'

EXECUTE 'SELECT SALES SAVING MULTIVALUED PART'

or a paragraph might perform the same action with

PA

SELECT SALES SAVING MULTIVALUED PART

DATA LIST STOCK

Note that DATA statements always follow the command to which they apply in a paragraph.

 

This mechanism originated in Pick style databases where a Proc might contain

PQ

STON

HLIST STOCK

STOFF

HSELECT SALES SAVING MULTIVALUED PART

P

or, resequencing the commands,

PQ

HSELECT SALES SAVING MULTIVALUED PART

STON

HLIST STOCK

P

 

The chaining process can continue over multiple selections, taking one command at a time from the data queue:

PA

SELECT VOUCHERS SAVING SALE

DATA SELECT SALES SAVING UNIQUE MULTIVALUED PART

DATA LIST STOCK