BITAND Syntax bitand::= Text description of bitand Purpose BITAND computes an AND operation on the bits of argument1 and argument2, both of which must resolve to nonnegative integers, and returns an integer. This function is commonly used with the DECODE function, as illustrated in the example that follows. -------------------------------------------------------------------------------- Note: This function does not determine the datatype of the value returned. Therefore, in SQL*Plus, you must specify BITAND in a wrapper, such as TO_NUMBER, which returns a datatype.-------------------------------------------------------------------------------- Examples The following represents each order_status in the sample table oe.orders by individual bits. (The example specifies options that can total only 7, so rows with order_status greater than 7 are eliminated.)SELECT order_id, customer_id, DECODE(BITAND(order_status, 1), 1, 'Warehouse', 'PostOffice') Location, DECODE(BITAND(order_status, 2), 2, 'Ground', 'Air') Method, DECODE(BITAND(order_status, 4), 4, 'Insured', 'Certified') Receipt FROM orders WHERE order_status < 8; ORDER_ID CUSTOMER_ID LOCATION MET RECEIPT ---------- ----------- ---------- --- --------- 2458 101 Postoffice Air Certified 2397 102 Warehouse Air Certified 2454 103 Warehouse Air Certified 2354 104 Postoffice Air Certified 2358 105 Postoffice G Certified 2381 106 Warehouse G Certified 2440 107 Warehouse G Certified 2357 108 Warehouse Air Insured 2394 109 Warehouse Air Insured 2435 144 Postoffice G Insured 2455 145 Warehouse G Insured . . .
Syntax
bitand::=
Text description of bitand
Purpose
BITAND computes an AND operation on the bits of argument1 and argument2, both of which must resolve to nonnegative integers, and returns an integer. This function is commonly used with the DECODE function, as illustrated in the example that follows.
--------------------------------------------------------------------------------
Note:
This function does not determine the datatype of the value returned. Therefore, in SQL*Plus, you must specify BITAND in a wrapper, such as TO_NUMBER, which returns a datatype.--------------------------------------------------------------------------------
Examples
The following represents each order_status in the sample table oe.orders by individual bits. (The example specifies options that can total only 7, so rows with order_status greater than 7 are eliminated.)SELECT order_id, customer_id,
DECODE(BITAND(order_status, 1), 1, 'Warehouse', 'PostOffice')
Location,
DECODE(BITAND(order_status, 2), 2, 'Ground', 'Air') Method,
DECODE(BITAND(order_status, 4), 4, 'Insured', 'Certified') Receipt
FROM orders
WHERE order_status < 8; ORDER_ID CUSTOMER_ID LOCATION MET RECEIPT
---------- ----------- ---------- --- ---------
2458 101 Postoffice Air Certified
2397 102 Warehouse Air Certified
2454 103 Warehouse Air Certified
2354 104 Postoffice Air Certified
2358 105 Postoffice G Certified
2381 106 Warehouse G Certified
2440 107 Warehouse G Certified
2357 108 Warehouse Air Insured
2394 109 Warehouse Air Insured
2435 144 Postoffice G Insured
2455 145 Warehouse G Insured
.
.
.