WHEN

WHEN

Top  Previous  Next

 

The WHEN keyword introduces a selection clause for a multivalued field.

 

 

Format

 

WHEN condition

 

where

 

condition isfield1 operator field2        to compare two fields
orfield1 operator value        to compare a field with a literal value

 

operator isany of the query processor operators:

EQ

=

EQUAL

 

 

NE

#

NOT

<>

><

LT

<

LESS

BEFORE

 

LE

<=

=<

 

 

GT

>

GREATER

AFTER

 

GE

>=

=>

 

 

LIKE

MATCHES

MATCHING

 

 

UNLIKE

NOT.MATCHING

 

 

 

SAID

SPOKEN

~

 

 

NO

 

 

 

 

BETWEEN

 

 

 

 

 

 

A selection clause specifies criteria governing which records are processed by the command. If omitted, all records are processed. The WHEN clause performs selection on exploded values from within the named multivalued field, showing only the selected value of the named field and all associated fields

 

Field comparisons are performed using the internal format of field1, converting the field2 or value item to this format if required. Thus a field holding an internal date, for example, may be compared with the more natural external form of the date. For example,

 

LIST INVOICES WHEN ISSUE.DATE > "12 OCT 96"

 

will list all invoice records with an issue date after 12 October 1996.

 

Prior to release 3.2-5 the WHEN clause filtering was not applied to SELECT commands. This incorrect behaviour can be continued in later releases by use of the NO.SEL.WHEN.FILTER setting of the OPTION command if needed.

 

 

Example

 

The command

 

LIST SALES WITH PART = 100

 

to find only orders containing part 100 might produce a report such as

 

LIST SALES WITH PART = 100

Order    Part    Qty

10001    100       4

        107       3

        219       3

10021    100       3

        206       3

        219       7

10014    105       3

        100       1

        210       7

 

3 records listed.

 

 

For the same data, use of the WHEN keyword to select only part 100 with a query such as

 

LIST SALES WHEN PART = 100

 

would produce the report below.

 

LIST SALES WHEN PART = 100

Order    Part    Qty

10001    100       4

10021    100       3

10014    100       1

 

3 records listed.