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

Returns the number of occurrences of a field.
Synopsis
ENUM field [NO.NULLS]
Description
The ENUM clause counts the number of occurrences of a field. It counts every occurrence of the specified field, including nulls (items that do not contain a value). You can use the NO.NULLS keyword to limit the ENUM count to non-null values.
The following example uses ENUM to count all of the occurrences of the F5 field, and TOTAL to return the total of these values:
LIST VOC ENUM F5 TOTAL F5 DET-SUPP
returns:
VOC......... F5............. F5.............
 
 
***                      478 52
 
478 Items listed.
In this example, the DET-SUPP keyword suppresses the listing of individual items.
The following example uses the NO.NULLS keyword to limit the ENUM count to all non-null occurrences of the F5 field:
LIST VOC ENUM F5 NO.NULLS TOTAL F5 DET-SUPP
returns:
VOC......... F5............. F5.............
 
 
***                       48 52
 
478 Items listed.
To just return the count of occurrences of a field, you can use the COUNT command. To count all occurrences:
COUNT VOC F5
To count all non-null occurrences:
COUNT VOC F5 WITH F5
ENUM with BREAK.ON
You can use the BREAK.ON clause with ENUM to return subcounts for each distinct value, as well as an overall count.
The following example counts the number of occurrences of each distinct value for F4, and the final count of all F4 values. These counts include a count of F4 fields with no value (null):
LIST VOC BY F4 BREAK.ON F4 ENUM F4 DET-SUPP
The following example counts the number of occurrences of each distinct non-null value for F4, and the final count of all non-null F4 values:
LIST VOC BY F4 BREAK.ON F4 ENUM F4 NO.NULLS DET-SUPP
Note that this example displays a line for the F4 nulls, with an ENUM subcount of 0. This indicates that there are one or more nulls, but they are not being added to the final count.
The following example also counts the number of occurrences of each distinct non-null value for F4, and the final count of all non-null F4 values:
LIST VOC WITH F4 BY F4 BREAK.ON F4 ENUM F4 DET-SUPP
The WITH F4 conditional clause is applied before ENUM; it restricts the result set to non-null values. Therefore ENUM does not indicate the presence (or absence) of nulls.