Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?

SAMPLE clause

Limits number of items returned.

Synopsis

SAMPLE n

Arguments

n An integer specifying the number of items to return.

Description

The SAMPLE clause limits the number of items returned by the query to the first n items. It thus gives a sample of the items that fulfill the query conditions. If n is 0 or a negative integer, all items are returned. If n is larger than the total number of items, all items are returned.

When multiple CMQL clauses are specified the clauses may be specified in any order. The order of application of CMQL clauses is as follows: the WITH clause is always applied first. Its results are supplied to the SAMPLED clause (if present), and the results are supplied to the SAMPLE clause (if present).

Examples

The following example lists the first five items in the VOC:

LIST VOC SAMPLE 5

It lists #, &COMO&, &PH&, &SAVEDLISTS&, and ;.

The following example lists the first five items in the VOC that fulfill the SAMPLED clause:

LIST VOC SAMPLED 50 SAMPLE 5

It lists #, BY.EXP, CREATE.FILE, ENUMERATE, and IF.

The following example lists the first three items in the VOC that are specified in the fields list:

LIST VOC 'ASSOC' 'BY.EXP' 'DUMMY' 'ASC' 'ASD' SAMPLE 3

It lists the three fields in the order listed: ASSOC, BY.EXP, and ASC. The DUMMY field is not listed because it is not found in the VOC.

See Also

Feedback