Hitachi

Hitachi Advanced Database SQL Reference


8.12.6 HEX

Converts binary data to a hexadecimal string representation (character string data consisting of 0 to 9, and A to F).

Organization of this subsection

(1) Specification format

scalar-function-HEX ::= HEX(target-data)
 
  target-data ::= value-expression

(2) Explanation of specification format

target-data:

Specifies the target binary data.

The following rules apply:

  • Specify the target data in the form of a value expression. For details about value expressions, see 7.20 Value expression.

  • Specify BINARY or VARBINARY type data for the target data.

  • You cannot specify a dynamic parameter by itself for the target data.

  • You cannot specify binary data whose defined length is 16,001 bytes or greater for the target data.

The following example illustrates the result of executing the scalar function HEX.

Examples:

HEX(B'10100100')'A4'

HEX(X'1234')'1234'

(3) Rules

  1. The data type and data length of the execution result are shown in the following table.

    Table 8‒57: Data type and data length of the execution result of the scalar function HEX

    Data type and data length of target data

    Data type and data length of the execution result

    Data type

    Defined length

    Actual length

    Data type

    Defined length

    Actual length

    BINARY(n)

    1 ≤ n ≤ 16,000

    Not applicable.

    VARCHAR

    n × 2

    n × 2

    VARBINARY(n)

    1 ≤ n ≤ 16,000

    r

    r × 2

    Legend:

    n: Defined length of target data

    r: Actual length of target data

  2. The NOT NULL constraint does not apply to the value of the execution result (the null value is allowed).

  3. If the target data has a null value, the execution result will be a null value.

  4. If the actual length of the target data is 0 bytes, the execution result will be data with an actual length of 0 bytes.