The LIKE phrase defines a mask for comparing characters:
WHERE COL_VAL [NOT] LIKE mask
WHERE COL_VAL [NOT] LIKE mask
A mask may be a host variable or a literal enclosed in quotes and may contain any number of:
character literal
| |
for an exact match
|
underscore character
|
_
|
for any single character
|
percent sign character
|
%
|
for any sequence of characters of length 0 or more
|
For example:
|
'NEW %'
|
masks
|
'NEW YORK' but not 'NEWARK'
| |
'T_N'
|
masks
|
'TAN', 'TIN', or 'TON', but not 'TUNE'
| ||
|
'T_N%'
|
masks
|
'TUNE'
| |
|
'%CA%'
|
masks
|
'CAT', 'GO CART', 'MOCA', etc.
| |
|
'%CA% '
|
masks
|
'CAT ' but not 'CAT'
|
To
use a host variable for a mask to produce the same effect as the
literal mask in the second-to-last example, code it right-padded with
“%” characters to avoid the effect of the last example.
05 WS-MASK PIC X(6) VALUE '%CA%%%'.
The IN phrase chooses from a given set:
WHERE COL_VAL [NOT] IN (:HOST-VAR, 'LITERAL', COL1 + COL2, ...)
WHERE COL_VAL [NOT] IN (:HOST-VAR, 'LITERAL', COL1 + COL2, ...)
Multiple list items that contain the same value are considered as a single item.
The BETWEEN phrase chooses from a range of inclusive limits:
WHERE COL_VAL [NOT] BETWEEN [:HOST-VAR1, 'LIT1']
AND [:HOST-VAR2, 'LIT2']
No comments:
Post a Comment