BITOR
functionsupportedCore SQL functionsReturns the bitwise OR of two numeric or binary expressions.
Syntax
supportedpartialnot supportednot scored
BITOR( <expr1> , <expr2> [ , '<padside>' ] )
Parameters
| Name | Required | Description |
|---|---|---|
expr1 | required | This expression must evaluate to an INTEGER value, a BINARY value, or a value of a data type that can be cast to an INTEGER value. |
expr2 | required | This expression must evaluate to an INTEGER value, a BINARY value, or a value of a data type that can be cast to an INTEGER value. |
'padside' | required | When two BINARY argument values are not the same length, specifies which side to pad the value with the shorter length. Specify one of the following case-insensitive values: LEFT - Pad the value on the left. RIGHT - Pad the value on the right. The shorter value is padded with zeros so that it equals the length of the larger value. This argument is valid only when BINARY expressions are specified. If the length of two BINARY values are different, this argument is required. |
Returns
Returns an INTEGER value, a BINARY value, or NULL: - When the input expressions contain INTEGER values, returns an INTEGER value that represents the bitwise OR of the input expressions. - When the input expressions contain BINARY values, returns a BINARY value that represents the bitwise OR of the input expressions. - If either input value is NULL, returns NULL.
Usage notes
- Both input expressions must evaluate to a value of the same data type, either INTEGER or BINARY.
- If the data type of either argument is numeric but not INTEGER (e.g. FLOAT, DECIMAL, etc.), then the argument is cast to an INTEGER value.
- If the data type of either argument is a string (e.g. VARCHAR), then the argument is cast to an INTEGER value if possible. For example, the string 12.3 is cast to 12. If the value cannot be cast to an INTEGER value, then the value is treated as NULL.
- The function does not implicitly cast arguments to BINARY values.
Using BITAND, BITOR, and BITXOR with INTEGER argument values
Create a simple table and insert the data: Run the query:
Using BITAND, BITOR, and BITXOR with BINARY argument values
Create a simple table and insert the data: Note The BINARY values are inserted using the x'value' notation, where value contains hexadecimal digits. For more information, see Binary input and output. Run a query on BINARY columns of the same length: If you try to run a query on BINARY columns of different lengths without specifying the 'padside' argument, an error is returned: Run a query on BINARY columns of different lengths, and pad the smaller argument value on the left: Run a query on BINARY columns of different lengths, and pad the smaller argument value on the right: