Skip to main content

CHOOSEN

CHOOSEN(recordset, n [, startpos ] [, FEW] [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )

recordsetThe 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.
nThe 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.
startposOptional. The ordinal position in the recordset of the first record to return. If omitted, the default is one (1).
FEWOptional. 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.
UNORDEREDOptional. Specifies the output record order is not significant.
ORDEREDSpecifies the significance of the output record order.
boolWhen False, specifies the output record order is not significant. When True, specifies the default output record order.
STABLEOptional. Specifies the input record order is significant.
UNSTABLEOptional. Specifies the input record order is not significant.
PARALLELOptional. Try to evaluate this activity in parallel.
numthreadsOptional. Try to evaluate this activity using numthreads threads.
ALGORITHMOptional. Override the algorithm used for this activity.
nameThe 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