Skip to main content


EXISTS(recordset [, KEYED ] [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )

EXISTS( valuelist )

recordsetThe 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.
KEYEDOptional. Specifies the activity is part of an index read operation, which allows the optimizer to generate optimal code for the operation.
valuelistA comma-delimited list of expressions. This may also be a SET of values.
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: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.


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