TO_MULTI_BYTE scalar function

The TO_MULTI_BYTE function returns a Unicode string in which the single-byte characters in a string-expression are converted to their multi-byte (full width) equivalents.

Read syntax diagramSkip visual syntax diagram TO_MULTI_BYTE ( string-expression )

The schema is SYSIBM.

string-expression
An expression that returns a value of a built-in character string.
A character string must not be bit data.
The argument can be also a numeric data type.
The numeric argument is implicitly cast to a VARCHAR data type.

Result

The result of the function is VARCHAR.

The result string unit is the same as string-expression.

The result length attribute depends on the string units as follows:
  • If string unit is OCTETS, the result length attribute is the minimum of three times the length attribute of string-expression and the maximum length for the result data type.
  • Otherwise, the result length attribute is the same as string-expression.

If the actual length of the result string exceeds the maximum for the return type, an error occurs (SQLSTATE 54006).

If the argument can be null, the result can be null. If the argument is null, the result is the null value.

Example

In the following example, the query returns the original single-byte string ‘ABC’, the full width equivalent, and the hexadecimal representation of the full width equivalent:

SELECT S, TO_MULTI_BYTE(S) MB, HEX(TO_MULTI_BYTE(S)) HEX
FROM (VALUES 'ABC') T(S)
S   MB        HEX

------------------------------
ABC ABCEFBCA1EFBCA2EFBCA3

1 record(s) selected.