Oracle9i SQL Reference Release 1 (9.0.1) Part Number A90125-01 |
|
Functions, 14 of 166
bitand::=
bitand
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.
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 . . .
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|