ROW and LIST comparisons
You can compare ROWs and LISTs against other ROWs and LISTs.
Examples
Example 1
IF ROW(InputBody.Data.*[1],InputBody.Data.*[2]) =
ROW('Raf' AS Name,'25' AS Age) THEN ...
IF LIST{InputBody.Data.Name, InputBody.Data.Age} = LIST{'Raf','25'} THEN ...
With
the following XML input message body both the IF expressions in both
the above statements evaluate to TRUE: <Data>
<Name>Raf</Name>
<Age>25</Age>
</Data>
In the comparison between ROWs, both the
name and the value of each element are compared; in the comparison
between LISTs only the value of each element is compared. In both
cases, the cardinality and sequential order of the LIST or ROW operands
being compared must be equal in order for the two operands to be
equal. Therefore, the following examples are false because either
the sequential order or the cardinality of the operands being compared
do not match: ROW('alpha' AS A, 'beta' AS B) =
ROW('alpha' AS A, 'beta' AS B, 'delta' AS D)
ROW('alpha' AS A, 'beta' AS B) =
ROW('beta' AS B,'alpha' AS A)
LIST{1,2,3} = LIST{1,2,3,4}
LIST{3,2,1} = LIST{1,2,3}
Example 2
Consider
the following ESQL:
IF InputBody.Places =
ROW('Ken' AS first, 'Bob' AS second, 'Kate' AS third) THEN ...
With
the following XML input message body, the above IF expression evaluates
to TRUE: <Places>
<first>Ken</first>
<second>Bob</second>
<third>Kate</third>
</Places>
The presence of an explicitly-constructed ROW as one of the operands to the comparison operator results in the other operand also being treated as a ROW.
Contrast this
with a comparison such as:
IF InputBody.Lottery.FirstDraw = InputBody.Lottery.SecondDraw THEN ...
which
compares the value of the FirstDraw and SecondDraw fields, not the
names and values of each of FirstDraw and SecondDraw's child fields
constructed as a ROW. Thus an XML input message body such as: <Lottery>
<FirstDraw>wednesday
<ball1>32</ball1>
<ball2>12</ball2>
</FirstDraw>
<SecondDraw>saturday
<ball1>32</ball1>
<ball2>12</ball2>
</SecondDraw>
</Lottery>
would not result in the above IF expression
being evaluated as TRUE, because the values wednesday and saturday
are being compared, not the names and values of the ball fields.Example 3
Consider
the following ESQL:
IF InputBody.Cities.City[] = LIST{'Athens','Sparta','Thebes'} THEN ...
With
the following XML input message body, the IF expression evaluates
to TRUE: <Cities>
<City>Athens</City>
<City>Sparta</City>
<City>Thebes</City>
</Cities>
Two message field arrays can be
compared together in this way, for example:
IF InputBody.Cities.Mediaeval.City[] =
InputBody.Cities.Modern.City[] THEN ...
IF InputBody.Cities.Mediaeval.*[] = InputBody.Cities.Modern.*[] THEN ...
IF InputBody.Cities.Mediaeval.(XML.Element)[] =
InputBody.Cities.Modern.(XML.Element)[] THEN ...
With
the following XML input message body, the IF expression of the first
and third of the statements above evaluates to TRUE: <Cities>
<Mediaeval>1350
<City>London</City>
<City>Paris</City>
</Mediaeval>
<Modern>1990
<City>London</City>
<City>Paris</City>
</Modern>
</Cities>
However the IF expression of the second
statement evaluates to FALSE, because the *[] indicates that all the
children of Mediaeval and Modern are to be compared, not just the
(XML.Element)s. In this case the values 1350 and 1990, which form
nameless children of Mediaeval and Modern, are compared as well as
the values of the City tags.The IF expression of the third
statement above evaluates to TRUE with an XML input message body such
as:
<Cities>
<Mediaeval>1350
<Location>London</Location>
<Location>Paris</Location>
</Mediaeval>
<Modern>1990
<City>London</City>
<City>Paris</City>
</Modern>
</Cities>
LISTs are composed of unnamed values. It
is the values of the child fields of Mediaeval and Modern that are
compared, not their names.