IBM ISERIES SC41-5210-04 User Manual

Page 112

Advertising
background image

DBCS-only LIKE, NLIKE (not like) pattern in Query for iSeries: This pattern, which contains only
double-byte characters, can be used for any bracketed-DBCS field, but not for a DBCS-graphic field. Start
the pattern with a shift-out character and end it with a shift-in character. Use the DBCS percent sign (%%)
to skip any number of characters or none at all. Use the DBCS underscore (__) to indicate that any
double-byte character is accepted for that position. Although the LIKE pattern contains only double-byte
characters, it can test DBCS-open fields that contain both double-byte character data and alphanumeric
data because a %% sign can skip over both kinds of data.

DBCS-open LIKE, NLIKE (not like) pattern in Query for iSeries: This pattern, which contains both
DBCS and SBCS character data, can be used only for DBCS-open fields.
v The percent sign (%) skips any number of SBCS characters or double-byte characters, or none at all. It

ignores shift-out and shift-in characters.

v The DBCS percent sign (%%) works the same way as the standard percent sign (%).
v The underscore (_) represents one SBCS character. It does not represent a double-byte, shift-out, or

shift-in character.

v The DBCS underscore (__) represents one double-byte character. It cannot be used to represent an

alphanumeric, shift-out, or shift-in character.

DBCS-Graphic LIKE, NLIKE (not like) pattern in Query for iSeries: This pattern, which contains only
double-byte characters, can be used only for a DBCS-graphic field. A DBCS-graphic test pattern must
have an uppercase or lowercase G before the apostrophe. Within the apostrophes, the pattern must start
with a shift-out character and end with a shift-in character. Use the DBCS percent sign (%%) to skip any
number of characters or none at all. Use the DBCS underscore (__) to indicate that any double-byte
character is accepted for that position.

Examples: In the following examples,

%% represents the DBCS percent sign, __ represents the DBCS

underscore,

s/o represents the shift-out character, s/i represents the shift-in character, and a pair of the

same SBCS characters, such as

DD, represent a single DBCS character.

Example 1:

DBCSFLD1

LIKE

’s/o__DD__%%HH%%s/i’

Example 1 selects only records in which the second character in field

DBCSFLD1 is DD, the first and third

characters are any double-byte characters, and at least one of the fourth through last characters is

HH.

This test could be used for any bracketed-DBCS field that is at least ten characters long. This test could
also be used for a DBCS-graphic field by putting a G in front of the test pattern:

G’s/o__DD__%%HH%%s/i’

If

DBCSFLD1 is a DBCS-open field, this test could select data that has alphanumeric characters, such as

‘s/oXXDDMMs/iAnns/oGGHHs/i’, for which the DBCS percent sign would skip over both double-byte
characters and alphanumeric characters before reaching

HH.

Example 2:

DBCSFLD2

LIKE

’s/o%%__%%s/i’

Example 2 selects only records in which field

DBCSFLD2 contains at least one double-byte character. The

DBCS underscore (__) can stand for a double-byte character, but not for an alphanumeric character. A
different value,

‘%_%’, selects records that have at least one alphanumeric character. A value of

‘s/o__________s/i’ selects those that have all double-byte characters for a field that is ten characters
long.

Example 3:

DBCSFLD3

LIKE

’s/oYY%%s/i A_o’

Example 3 selects all records in which the field

DBCSFLD3 begins with the double-byte character YY and

ends with alphanumeric characters, the first of which is blank, the second of which is

A, and the fourth of

which is

o. This test selects fields such as ‘s/oYYs/i Amo’; ‘s/oYYZZXXs/iMary Abo’; or

‘s/oYYs/iABCs/oTTWWs/iM Aro’. It is not important that the percent between the double-byte character and
alphanumeric parts of the value is a DBCS percent; the following two values are equivalent to the one
used:

‘s/oYY%s/i A_o’ and ‘s/oYY%%s/i% A_o’.

100

Query for iSeries Use V5R2

Advertising