SQL/MX Report Writer Guide
Selecting Data for a Report
HP NonStop SQL/MX Report Writer Guide—527194-002
3-12
Comparing Character Values
Use the LIKE predicate to search for similar values by specifying only a few characters
and using these wild-card characters:
Character data can be stored in columns of data type CHAR, PIC X, VARCHAR,
NATIONAL CHAR, and NCHAR.
PIC X columns, and CHAR, NATIONAL CHAR, and NCHAR columns defined without
the VARYING clause, contain fixed-length values. Every row of the table contains a
value of the same length in the column. When you insert a value, report writer fills the
value with blanks if necessary.
VARCHAR columns, and CHAR, NATIONAL CHAR, AND NCHAR columns defined
with the VARYING clause contain variable-length values. Values vary in length from
row to row. When you insert a value, only the characters you enter are stored.
The following rules describe how report writer compares character values in
comparison and LIKE predicates based on these rules. (BETWEEN and IN predicates
follow the same rules as comparison predicates.)
•
Trailing blanks are significant for fixed-length columns. For example, the value
’DISK’ inserted in a CHAR(6) column is ’DISK’.
•
Only the data inserted is significant for variable-length columns. For example, the
value ’DISK’ inserted in a VARCHAR(6) column is ’DISK’.
•
When processing comparison predicates, the comparison value or the column
value (whichever is smaller) are padded to make the values the same length.
•
The column value for LIKE predicates is not padded with blanks.
•
Unless you specify a % wild-card character in the comparison value, the condition
is met only if the column value and the comparison value are the same length.
Table 3-2
provides examples to illustrate these rules.
% (percent sign) Indicates zero or more characters of any type are acceptable.
_ (underscore) Indicates any single character is acceptable.