Hitachi

Hitachi Advanced Database SQL Reference


8.11.6 BITXOR

Returns the bitwise exclusive OR of two binary data items.

Organization of this subsection

(1) Specification format

scalar-function-BITXOR ::= BITXOR(target-data-1,target-data-2)
 
  target-data-1 ::= value-expression
  target-data-2 ::= value-expression

(2) Explanation of specification format

target-data-1 and target-data-2:

Specifies the target binary data.

The following rules apply:

  • Specify target-data-1 and target-data-2 in the form of value expressions. For details about value expressions, see 7.20 Value expression.

  • Specify BINARY or VARBINARY type data for target-data-1 and target-data-2.

  • Make sure that target-data-1 and target-data-2 have the same data length (if the target data is BINARY type), or actual length (if the target data is VARBINARY type).

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

  • If you specify a dynamic parameter by itself for target-data-2, the data type and data length of target-data-1 are assumed for the data type and data length of the dynamic parameter.

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

Examples:

Return the bitwise exclusive OR of two binary data items.

BITXOR(B'01011011',B'01001110')B'00010101'

BITXOR(B'01011011',X'FF')B'10100100'

BITXOR(X'0F',X'FF')X'F0'

(3) Rules

  1. The execution result of the scalar function BITXOR (value of the nth bit) is shown in the following table.

    Table 8‒42: Execution result of the scalar function BITXOR (value of the nth bit)

    Value of the nth bit of target-data-1

    Value of the nth bit of target-data-2

    Execution result of the scalar function BITXOR (value of the nth bit)

    0

    0

    0

    1

    1

    1

    0

    1

    1

    0

  2. The data type and data length of the execution result are determined by the data types and data lengths of target-data-1 and target-data-2. The data type and data length of the execution result of the scalar function BITXOR are shown in the following table.

    Table 8‒43: Data type and data length of the execution result of the scalar function BITXOR

    Data type and data length of target-data-1

    Data type and data length of target-data-2

    Data type and data length of the execution result

    BINARY(m)

    BINARY(m)

    BINARY(m)

    VARBINARY(Y)

    Actual length of target data: m

    VARBINARY(Y)

    Actual length of target data: m

    VARBINARY(X)

    Actual length of target data: m

    BINARY(m)

    VARBINARY(X)

    Actual length of target data: m

    VARBINARY(Y)

    Actual length of target data: m

    VARBINARY(MAX(X,Y))

    Actual length of target data: m

    Legend:

    m: Data length or actual length

    X: Data length (when Xm)

    Y: Data length (when Ym)

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

  4. If either target-data-1 or target-data-2 has a null value, the execution result will be a null value.

  5. If the actual length of target-data-1 and target-data-2 is 0 bytes, the execution result will be binary data whose actual length is 0 bytes.