EXISTS(recordset [, KEYED ] [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )
EXISTS( valuelist )
recordset | The set of records to process. This may be the name of an index, a dataset, or a record set derived from some filter condition, or any expression that results in a derived record set. |
KEYED | Optional. Specifies the activity is part of an index read operation, which allows the optimizer to generate optimal code for the operation. |
valuelist | A comma-delimited list of expressions. This may also be a SET of values. |
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: | EXISTS returns a single BOOLEAN value. |
The EXISTS function returns true if the number of records in the specified recordset is > 0, or the valuelist is populated. This is most commonly used to detect whether a filter has filtered out all the records.
When checking for an empty recordset, use the EXISTS(recordset) function instead of the expression: COUNT(recordset) > 0. Using EXISTS results in more efficient processing and better performance under those circumstances.
Example:
MyBoolean := EXISTS(Publics(pub_type = 'B')); TradesExistPersons := Person(EXISTS(Trades)); NoTradesPerson := Person(NOT EXISTS(Trades)); MinVal2 := EXISTS(4,8,16,2,1); //returns TRUE SetVals := [4,8,16,2,1]; MinVal3 := EXISTS(SetVals); //returns TRUE NullSet := []; MinVal3 := EXISTS(NullSet); //returns FALSE
See Also: DEDUP, Record Filters