The IS_EMPTY and IS_NOT_EMPTY functions determine whether a set is or is not empty. The IS EMPTY and IS NOT EMPTY functions provide alternative syntaxes for these functions.
Rec ID Body attribute --------------------------- | 16 | { Silky, Tannins } | | 17 | { } | | 18 | { Silky, Tannins } | | 19 | { Fresh, Robust } | | 20 | { } | | 21 | { } | | 22 | { Firm, Robust } | ---------------------------
Three of the records have no Body assignment (and therefore are empty sets), while the other three records have two Body assignments.
Note that these functions are used in WHERE clauses in the examples. However, they can be used anywhere that an arbitrary expression can be used, such as in SELECT and HAVING clauses.
IS_EMPTY(<set>)where set is a set of any set data type (such as mdex:string-set or mdex:long-set). For example, set can be a multi-assign double attribute.
IS_EMPTY({ }) = TRUE IS_EMPTY({ 1 }) = FALSE
RETURN results AS SELECT WineID AS idRec, Body AS bodyAttr WHERE (WineID BETWEEN 16 AND 22) AND (IS_EMPTY(Body)) ORDER BY idRec
idRec ------ | 17 | | 20 | | 21 | ------
In the result, only Records 17, 20, and 21 are returned because they have an empty Body set.
The IS EMPTY function provides an alternative syntax to IS_EMPTY and also returns TRUE if that set is empty.
<set> IS EMPTYwhere set is a set of any set data type, such as a multi-assign double attribute.
RETURN results AS SELECT WineID AS idRec, Body AS bodyAttr WHERE (WineID BETWEEN 16 AND 22) AND (Body IS EMPTY) ORDER BY idRec
The results of this example would the same as the previous IS_EMPTY example.
IS_NOT_EMPTY(<set>)where set is a set of any set data type. For example, set can be a multi-assign geocode attribute.
IS_NOT_EMPTY({ }) = FALSE IS_NOT_EMPTY({ 1 }) = TRUE
RETURN results AS SELECT WineID AS idRec, Body AS bodyAttr WHERE (WineID BETWEEN 16 AND 22) AND (IS_NOT_EMPTY(Body)) ORDER BY idRec
bodyAttr idRec ---------------------------- | { Silky, Tannins } | 16 | | { Silky, Tannins } | 18 | | { Fresh, Robust } | 19 | | { Firm, Robust } | 22 | ----------------------------
In the result, Records 16, 18, 19, and 22 are returned because they have non-empty Body sets. However, Records 17, 20, and 21 are not returned because there is no Body assignment for those records (and therefore those sets would be empty).
The IS NOT EMPTY function provides an alternative syntax to IS_NOT_EMPTY and also returns TRUE if that set is not empty.
<set> IS NOT EMPTYwhere set is a set of any set data type, such as a multi-assign string attribute.
RETURN results AS SELECT WineID AS idRec, Body AS bodyAttr WHERE (WineID BETWEEN 16 AND 22) AND (Body IS NOT EMPTY) ORDER BY idRec
The results of this example would the same as the previous IS_NOT_EMPTY example.