SINGULAR function

The SINGULAR function returns a BOOLEAN value indicating whether a list contains exactly one element.

SYNTAX

If the list specified by ListExpression contains exactly one element, SINGULAR returns TRUE. If the list contains more or fewer elements, SINGULAR returns FALSE.

ListExpression is any expression that returns a list. All the following, for example, return a list:
  • A LIST constructor
  • A field reference with the [] array indicator
  • Some SELECT expressions (not all return a list)

If you only want to know whether a list contains just one element or some other number, SINGULAR executes more quickly than an expression involving the CARDINALITY function (for example, CARDINALITY(ListExpression ) = 1).

A common use of this function is to determine whether a field is unique.

Examples

-- Determine whether there is just one F1 field in the message.
-- Note that the [ ] are required
DECLARE Field1Unique BOOLEAN SINGULAR(OutputRoot.XML.Data.Source.F1[]);
-- Determine whether there is just one field called F1 with the value 'F12'
-- in the message. Again note that the [ ] are required
DECLARE Field1F12Unique BOOLEAN
  SINGULAR(SELECT F.* FROM OutputRoot.XML.Data.Source.F1[] AS F where F = 'F12'); 
Related concepts
ESQL overview
Related tasks
Developing ESQL
Related reference
CARDINALITY function
EXISTS function
THE function
Syntax diagrams: available types
ESQL list functions