VARCHAR_FORMAT_BIT scalar function
The VARCHAR_FORMAT_BIT function returns a character representation of a bit string that has been formatted using a character template.
The schema is SYSIBM.
-
bit-data-expression
- An expression that returns a value that is a built-in character-string FOR BIT DATA data type (SQLSTATE 42815). The required length is determined by the specified format string and how the value is interpreted. format-string
- A character constant that contains a template for how the result
is to be formatted.
Valid format strings include:
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
and'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
(SQLSTATE 42815) where each 'x' or 'X' corresponds to one hexadecimal digit from bit-data-expression.
The result of the function is a varying-length character string with the length attribute and actual length based on the format string. If the string units of the environment or format-string is CODEUNITS32, the string units of the result is CODEUNITS32. Otherwise, the string units of the result is OCTETS For the two valid format strings listed previously, the length attribute is 36 and the actual length is 36 bytes. If the first argument can be null, the result can be null; if the first argument is null, the result is the null value.
Examples
- Example 1: Represent a Universal Unique Identifier in its
formatted form:
Result returned:VARCHAR_FORMAT_BIT(CAST(x'd83d6360181811db9804b622a1ef5492' AS VARCHAR(16) FOR BIT DATA), 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')
'd83d6360-1818-11db-9804-b622a1ef5492'
- Example 2: Represent a Universal Unique Identifier in its
formatted form:
Result returned:VARCHAR_FORMAT_BIT(CAST(x'd83d6360181811db9804b622a1ef5492' AS CHAR(16) FOR BIT DATA), 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX')
'D83D6360-1818-11DB-9804-B622A1EF5492'