PURPOSE: The COUNT command counts records in the current Data Set (DS) and displays the number at the terminal.
COUNT
[/USE/ DOMAIN name]
[WHEN clause]
[{IF; UNLESS} clause]
[{STOP; END} clause]
COUNT |
with no clauses counts all records in the current DS and updates the @RECORDS count in the Data Base Library (DBL). |
/USE/ DOMAIN name |
specifies the domain of a Data Index (DI). |
WHEN clause |
counts only records having the specified key field values when a DI is in use. Described in detail in Chapter 7. |
[{IF; UNLESS} clause] |
It limits counting to those records that pass the conditions DS. Described in detail in Chapter 7. |
{STOP; END} clause |
Described in detail in Chapter 7. |
*COUNT IF QTY < 50 AND TITLE_CODE BEGINS WITH "CP"
15 Records
*TYPE @QUALIFIED
15
*TYPE @UNQUALIFIED
37
The next example uses a DI to count the records in a DS that have a given zip code. The WHEN clause is much more efficient than an IF; UNLESS clause, since it reads only those records that have zip = 90732. An IF; UNLESS clause would read every record.
*COUNT USE DOMAIN ZIP WHEN ZIP = 90732
14 Records