Start of change

VARCHAR_FORMAT_BINARY

The VARCHAR_FORMAT_BINARY function returns a character string representation of a bit string that has been formatted using a format-string.

Read syntax diagramSkip visual syntax diagramVARCHAR_FORMAT_BINARY(expression ,format-string )
expression
An expression that returns a built-in binary string or character FOR BIT DATA string. The length of expression must be equal to the number of 'x' or 'X' characters in the format-string divided by 2.
format-string
An expression that returns a built-in character string or graphic string data type. format-string contains a template for how the value for expression is to be formatted.

Valid format strings are: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' and 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' where each 'x' or 'X' corresponds to one hexadecimal digit from expression. If 'x' is specified, the character returned for the corresponding hexadecimal digit will be lower case. Otherwise, the character returned will be upper case.

The result of the function is a varying-length character string with the length attribute and actual length based on the format string. For the two valid format strings, the length attribute and actual length of the result is 36. If either argument can be null, the result can be null; if either argument is null, the result is the null value.

The CCSID of the result is the CCSID of format-string.

Note

Syntax alternatives: VARCHAR_FORMAT_BIT is a synonym for VARCHAR_FORMAT_BINARY.

Example

  • Represent a Universal Unique Identifier in its formatted form:
    VALUES VARCHAR_FORMAT_BINARY(BX'd83d6360181811db9804b622a1ef5492', 
                                 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')
    Result returned:
    'd83d6360-1818-11db-9804-b622a1ef5492'
  • Represent a Universal Unique Identifier in its formatted form:
    VALUES VARCHAR_FORMAT_BINARY(BX'd83d6360181811db9804b622a1ef5492',
                                 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX')
    Result returned:
    'D83D6360-1818-11DB-9804-B622A1EF5492'
End of change