CHOOSEN(recordset, n [, startpos ] [, FEW] [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )
recordset | The set of records to process. This may be the name of a dataset or a record set derived from some filter condition, or any expression that results in a derived record set. |
n | The number of records to return. If zero (0), no records are returned, and if ALL or CHOOSEN:ALL, all records are returned. The CHOOSEN:ALL option is a constant that may be used in any expression. |
startpos | Optional. The ordinal position in the recordset of the first record to return. If omitted, the default is one (1). |
FEW | Optional. Specifies internally converting to a TOPN operation if n is a variable number (an attribute or passed parameter) and the input recordset comes from a SORT. |
UNORDERED | Optional. Specifies the output record order is not significant. |
ORDERED | Specifies the significance of the output record order. |
bool | When False, specifies the output record order is not significant. When True, specifies the default output record order. |
STABLE | Optional. Specifies the input record order is significant. |
UNSTABLE | Optional. Specifies the input record order is not significant. |
PARALLEL | Optional. Try to evaluate this activity in parallel. |
numthreads | Optional. Try to evaluate this activity using numthreads threads. |
ALGORITHM | Optional. Override the algorithm used for this activity. |
name | The algorithm to use for this activity. Must be from the list of supported algorithms for the SORT function's STABLE and UNSTABLE options. |
Return: | CHOOSEN returns a set of records. |
The CHOOSEN function (choose-n) returns the first n number of records, beginning with the record at the startpos, from the specified recordset.
Example:
AllRecs := CHOOSEN(Person,ALL); // returns all recs from Person FirstFive := CHOOSEN(Person,5); // returns first 5 recs from Person NextFive := CHOOSEN(Person,5,6); // returns next 5 recs from Person LimitRecs := CHOOSEN(Person,IF(MyLimit<>0,MyLimit,CHOOSEN:ALL));
See Also: SAMPLE, CHOOSESETS