Caché MultiValue Query Language (CMQL) Reference
WHEN clause
[Back] [Next]
   
Server:docs2
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Specifies a condition for query results.
Description
The WHEN clause is in most cases a synonym for the WITH clause. Refer to the WITH clause for details about condition expressions.
The WHEN clause differs from the WITH clause in the following respects:
WHEN ASSOCIATED
The WHEN ASSOCIATED clause permits a more sophisticated use of compound conditions, using XOR (exclusive OR) logic. The CMQL default is inclusive OR logic.
The following example uses inclusive OR logic:
LIST VOC F1 F4 WITH (F1="V" AND F4 # "") OR WITH @ID > "W"
returns “25 Items listed.” and displays a list of 25 items:
VOC.........  F1............. F4.............
 
BSELECT       V               L
COUNT.VERB    V               L
LIST          V               DA
LIST.ITEM     V               I
LIST.LABEL    V               D
PRINT.CATALOG V
REFORMAT      V               DA
SELECT        V               L
SORT          V               DAS
SORT.ITEM     V               IS
SORT.LABEL    V               DS
SREFORMAT     V               DAS
SSELECT       V               LS
STAT          V               J
SUM.VERB      V               T
WHEN          K
WHERE         K
WHERE.VERB    V
WHO           V
WITH          K
WITHIN        K
WITHOUT       K
Z             V
ZH            V
[             V

25 Items listed.
This example creates a result set by including or excluding items that meet each conditional expression.
The following WHEN ASSOCIATED statement uses exclusive OR (XOR) logic.
LIST VOC F1 F4 WHEN ASD (F1="V" AND F4 # "") OR WHEN @ID > "W"
The result set is selected using exclusive OR logic, but the count of items listed uses inclusive OR logic. Therefore, it returns “25 Items listed.” and displays a list of 20 items:
VOC.........  F1............. F4.............
 
BSELECT       V               L
COUNT.VERB    V               L
LIST          V               DA
LIST.ITEM     V               I
LIST.LABEL    V               D
PRINT.CATALOG V
REFORMAT      V               DA
SELECT        V               L
SORT          V               DAS
SORT.ITEM     V               IS
SORT.LABEL    V               DS
SREFORMAT     V               DAS
SSELECT       V               LS
STAT          V               J
SUM.VERB      V               T
WHERE.VERB    V
WHO           V
Z             V
ZH            V
[             V
 
25 Items listed.
This example creates a result set of all records with F1="V", then removes items that don’t meet the other conditional expression criteria from this result set.