CHOOSESETS( recset, condition => n [, o ][ , EXCLUSIVE | LAST | ENTH [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] ] )
recset | 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. |
condition | The logical expression that defines which records to include in the result set. |
=> | The "results in" operator--valid only in CHOOSESETS, CASE, and MAP. |
n | The maximum number of records to return. If zero (0), no records that meet the condition are returned. |
o | Optional. The maximum number of records to return that meet none of the conditions specified. |
EXCLUSIVE | Optional. Specifies the condition parameters are mutually exclusive. |
LAST | Optional. Specifies choosing the last n records that meet the condition instead of the first n. This option is implicitly EXCLUSIVE. |
ENTH | Optional. Specifies choosing a sample of records that meet the condition instead of the first n. This option is implicitly EXCLUSIVE. |
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: | CHOOSESETS returns a set of records. |
The CHOOSESETS function returns a set of records from the recset. The result set is limited to n number of records that meet each condition listed. CHOOSESETS may take as many condition => n parameters as needed to exactly specify the desired set of records. This is a shorthand way of concatenating the result sets of multiple CHOOSEN function calls to the same recset with different filter conditions, but CHOOSESETS executes significantly faster. This technique is also know as a "cutback."
Example:
MyResultSet := CHOOSESETS(Person,
per_first_name = 'RICHARD' => 100,
per_first_name = 'GWENDOLYN' => 200, 100)
// returns a set containing 100 Richards, 200 Gwendolyns, 100 others