In DB2 version 7 a feature called row value expression was introduced. A row value expression is a list of columns or constants which you can compare with another list of columns or constants with the same number of elements. You may also compare the list with the result of an IN subselect.
Let me
give you an example which hopefully is far more explanatory than a long verbal
description:
...
WHERE
A = 3
AND
B = 'THE SUN'
may be
written as:
...
WHERE
(A, B) = (3, 'THE SUN')
using a
row vaule expression. The above rewrite may save some keyboard work and in
other sitiations it may make your SQL more readable. When I explore such new
inventions in DB2 I cannot wait to try them out in other contexts.
Unfortunately the only other legal context is combined with an IN subselect:
...
WHERE
(A, B) IN
(
SELECT X, Y
FROM
ANOTHER_TABLE
)
When I executed the above SQL statement it took
a very, very long time before I got a reply while:...
WHERE
EXISTS
(
SELECT 0
FROM
ANOTHER_TABLE
WHERE
(A, B) = (X, Y)
)