IBM Integration Bus, Version 10.0.0.17 Operating Systems: AIX, HP-Itanium, Linux, Solaris, Windows, z/OS


EXISTS function

The EXISTS function returns a Boolean value to indicate whether a list contains at least one element (that is, whether the list exists).

Syntax

Read syntax diagramSkip visual syntax diagram
>>-EXISTS--(--ListExpression--)--------------------------------><

If the list specified by ListExpression contains one or more elements, EXISTS returns TRUE. If the list contains no elements, EXISTS returns FALSE.

ListExpression is any expression that returns a list. All the following expressions, 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 want to know only whether a list contains at least one elements or none, EXISTS executes more quickly than an expression involving the CARDINALITY function (for example, CARDINALITY(ListExpression ) <> 0).

A typical use of this function is to determine whether a field exists.

Examples

-- Determine whether the F1 array exists in the message. Note that the [ ]
-- are required
DECLARE Field1Exists BOOLEAN EXISTS(OutputRoot.XMLNS.Data.Source.F1[]);
-- Determine whether the F1 array contains an element with the value 'F12'.
-- Again note that the [ ] are required
DECLARE Field1F12Exists BOOLEAN 
  EXISTS(SELECT F.* FROM OutputRoot.XMLNS.Data.Source.F1[] AS F where F = 'F12');

ak05535_.htm | Last updated 2019-07-13 08:12:51