Setting Limits on the Number of Records Read

For some reports, a limited number of records is satisfactory. When the specified number of records is retrieved, record retrieval can stop. This is useful when:

  • You are designing a new report, and you need only a few records from the actual data source to test your design.
  • The database administrator needs to limit the size of reports by placing an upper limit on retrieval from very large data sources. This limit is attached to the user password.
  • You know the number of records that meet the test criteria. You can specify that number so that the search does not continue beyond the last record that meets the criteria. For example, suppose only ten employees use electronic transfer of funds, and you want to retrieve only those records. The record limit would be ten, and retrieval would stop when the tenth record is retrieved. The data source would not be searched any further.

Limit the Number of Records Read

There are two ways to limit the number of records retrieved. You can use

WHERE RECORDLIMIT EQ n

where:

n
Is a number greater than 0, and indicates the number of records to be retrieved. This syntax can be used with FOCUS and non-FOCUS data sources.

For all non-FOCUS data sources, you can also use

WHERE READLIMIT EQ n

where:

n
Is a number greater than 0, and indicates the number of read operations (not records) to be performed. For details, see the appropriate data adapter manual.

Tip: If an attempt is made to apply the READLIMIT test to a FOCUS data source, the request is processed correctly, but the READLIMIT phrase is ignored.

Note: Using SET RECORDLIMIT disables AUTOINDEX.

Limiting the Number of Records Read

The following request retrieves four records, generating a four-line report:

TABLE FILE EMPLOYEE
PRINT LAST_NAME AND FIRST_NAME AND EMP_ID
WHERE RECORDLIMIT EQ 4
END

The output is:

LAST_NAME        FIRST_NAME  EMP_ID   
---------        ----------  ------   
STEVENS          ALFRED      071382660
SMITH            MARY        112847612
JONES            DIANE       117593129
SMITH            RICHARD     119265415