SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
C-59
Considerations—Comparison Predicate
A HEX 20 is always used for padding, regardless of whether a single-byte or
double-byte character set is associated with the expression.
Both fixed-length and variable-length strings are padded in this way. For example,
SQL considers the string “JOE” equal to a value JOE stored in a column of data
type CHAR or VARCHAR of width three or more. Similarly, SQL considers a value
JOE stored in any column of the CHAR data type equal to the value JOE stored in
any column of the VARCHAR data type.
Two strings are equal if all characters in the same ordinal position are equal.
Lowercase and uppercase letters are not considered equivalent unless used with a
collation that equivalences them.
SQL determines collations for character comparisons:
If neither value is associated with a collation, use binary comparison.
If only one value is associated with a collation or if both values are associated
with the same collation, use that collation.
If each value is associated with a different collation but one collation is
specified implicitly and one collation is specified explicitly, use the collation that
is specified explicitly.
You cannot compare character values that are implicitly associated with
different collations unless you explicitly specify a collation for the comparison.
You cannot compare character values that are explicitly associated with
different collations. SQL returns an error if you attempt to do so.
For comparisons between numbers, decimal-type numbers are converted to binary.
Any exact numeric data type is compatible with all other exact numeric data types.
Floating-point data types are sometimes compatible with exact numeric data types.
Before evaluation, all values in an expression are first converted to the maximum
precision needed anywhere in the expression.
You can compare only those date-time values with the same range of datetime
fields. To compare two date-time values with a different range of fields, use the
EXTEND function to expand the values.
For example, to compare a DATETIME DAY TO MINUTE column with a
DATETIME YEAR TO HOUR column, expand both values to the range DATETIME
YEAR TO MINUTE for the comparison:
EXTEND (DATE1, YEAR TO DAY) > EXTEND (DATE2, YEAR TO DAY)
For information about the expansion, see EXTEND Function on page E-28.
For comparisons of INTERVAL values, SQL first converts the intervals to a
common base unit. If no common unit exists, SQL reports an error.
If a search condition contains a predicate of the form