Considerations For Comparison Predicates - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

row-value-constructor comparison-op row-value-constructor
comparison-op is:
=
| <>
| <
| >
| <=
| >=
row-value-constructor is:
(expression [,expression]...)
| row-subquery
row-value-constructor
specifies an operand of a comparison predicate. The two operands can be either of these:
(expression [,expression ]...)
is a sequence of SQL value expressions, separated by commas and enclosed in parentheses.
expression cannot include an aggregate function unless expression is in a HAVING
clause. expression can be a scalar subquery (a subquery that returns a single row
consisting of a single column). See
row-subquery
is a subquery that returns a single row (consisting of a sequence of values). See
(page
The two row-value-constructors must contain the same number of elements. That is,
the number of value expressions in each list, or the number of values returned by a row
subquery, must be the same.
The data types of the respective values of the two row-value-constructors must be
comparable. (Respective values are values with the same ordinal position in the two lists.)
See
"Comparable and Compatible Data Types" (page

Considerations for Comparison Predicates

When a Comparison Predicate Is True
Neoview SQL determines whether a relationship is true or false by comparing values in
corresponding positions in sequence, until it finds the first nonequal pair.
You cannot use a comparison predicate in a WHERE or HAVING clause to compare row value
constructors when the value expressions in one row value constructor are equal to null. Use the
IS NULL predicate instead.
Suppose that there are two rows with multiple components, X and Y:
X=(X1,X2,...,Xn), Y=(Y1,Y2,...,Yn).
Predicate X=Y is true if for all i=1,...,n: Xi=Yi. For this predicate, Neoview SQL must look
through all values. Predicate X = Y is false if for some i Xi<>Yi. When SQL finds nonequal
components, it stops and does not look at remaining components.
Predicate X<>Y is true if X=Y is false. If X1<>Y1, Neoview SQL does not look at all components.
It stops and returns a value of false for the X=Y predicate and a value of true for the X<>Y
predicate. Predicate X<>Y is false if X=Y is true, or for all i=1,...,n: Xi=Yi. In this situation,
Neoview SQL must look through all components.
Predicate X>Y is true if for some index m Xm>Ym and for all i=1,..,m-1: Xi=Yi. Neoview
SQL does not look through all components. It stops when it finds the first nonequal components,
Xm<>Ym. If Xm>Ym, the predicate is true. Otherwise the predicate is false. The predicate is also
false if all components are equal, or X=Y.
Equal
Not equal
Less than
Greater than
Less than or equal to
Greater than or equal to
250).
"Expressions" (page
208).
199).
"Subquery"
Predicates
235

Advertisement

Table of Contents
loading

Table of Contents