IBM ISERIES SC41-5210-04 User Manual

Page 76

Advertising
background image

v If the first argument is UCS2 graphic data and the result is mixed data, the result length is (2.5*(n-1)) +

4.

The third argument, if specified, must be a valid SBCS or mixed CCSID. If it is a SBCS CCSID, the first
argument cannot be a DBCS-either or DBCS-only string.

The result of the function is the character string that would result if the character string expression was
assigned to a varying-length host variable with a length attribute of n, where n is the length attribute of the
result. If the length attribute of the argument is greater than the length attribute of the result, truncation is
performed and no warning is returned.

The result data type is VARCHAR.

If the ccsid (third argument) is not specified:
v If the first argument is SBCS character, then the result is SBCS character. The CCSID of the result is

the same as the CCSID of the first argument.

v If the first argument is mixed (DBCS-open), DBCS-only, or DBCS-either then the result is mixed. The

CCSID of the result is the same as the CCSID of the first argument.

v If the first argument is non-UCS2 graphic, then the result is mixed. The CCSID of the result is the

associated mixed CCSID of the DBCS CCSID.

v If the first argument is UCS2 then the CCSID of the result is the job CCSID. If the job CCSID is mixed,

then the result type is mixed. If the job CCSID is SBCS, then the result is SBCS character.

If the ccsid is specified:
v The result is dependent on the specified CCSID. If ccsid is a SBCS CCSID, then the result type is

SBCS character. If ccsid is a mixed CCSID, then the result type is mixed character.

v The CCSID of the result is the ccsid.

If the first argument can be null, the result can be null; if the first argument is null, the result is the null
value.

Following are examples of using VARCHAR to convert from CHARACTER to VARCHAR and UCS-2
GRAPHIC to VARCHAR:

RESCHAR

varchar(char1,10,37)

where char1 is a character field to be converted

10 is the length of the output variable

37 is the ccsid of the output variable
RESUCS2

varchar(ucs2,8,37)

where ucs2 is a UCS-2 graphic field to be converted

8 is the length of the output variable

37 is the ccsid of the output variable

Following are examples of using VARCHAR to convert from CHARACTER to VARCHAR and UCS-2
GRAPHIC to VARCHAR:

RESCHAR

varchar(char1,10,37)

where char1 is a character field to be
converted, 10 is the length of the
output variable, and 37 is the CCSID
of the output variable

RESUCS2

varchar(ucs2,8,37)

where ucs2 is a UCS-2 graphic field
to be converted, 8 is the length of the
output variable, and 37 is the ccsid of
the output variable

64

Query for iSeries Use V5R2

|
|

||||
|
|
|

|||
|
|
|

Advertising