DB2 Version 10.1 for Linux, UNIX, and Windows

TO_SINGLE_BYTE scalar function

The TO_SINGLE_BYTE function returns a string in which multi-byte characters are converted to the equivalent single-byte character where an equivalent character exists.

Read syntax diagramSkip visual syntax diagram
>>-TO_SINGLE_BYTE--(--string-expression--)---------------------><

The schema is SYSIBM.

Only characters that have an equivalent to the single-byte characters represented by the characters in the UTF-8 code point range U+0020 to U+007E will be converted. If a multi-byte character does not have a single-byte equivalent, then it remains unchanged.

This function is only supported for database created in unicode and IBM-943 code page (SQLCODE 42997).

string-expression
An expression that specifies the string which gets converted. The expression must return a value that is a built-in CHAR or VARCHAR data type. In a Unicode database, if a supplied argument is a GRAPHIC or VARGRAPHIC data type, it is first converted to VARCHAR before evaluating the function. The expression cannot be a character string defined as FOR BIT DATA (SQLSTATE 42815).

The data type, code page and length attribute of the result is the same as the data type, code page and length attribute of the argument. If the argument can be null, the result can be null. If the argument is null, the result is the null value.

Example

Convert the full width UTF-8 characters 'ABC' (x'efbca1efbca2efbca3' in hex format) to their single byte equivalents.

   VALUES TO_SINGLE_BYTE(x'efbca1efbca2efbca3')

The result is the value 'ABC' (x'414243' in hex format).