Re: Handle Bitwise Field?
Date: Tue, 29 Sep 1998 09:04:45 GMT
Message-ID: <3610a104.8957364_at_news.siol.net>
On Mon, 28 Sep 1998 14:34:15 -0700, "Ashok Rathi" <arathi_at_impresse.com> wrote:
>If I have a column which is BITWISE-OR'ed combination of 4 values based on
>the bit position, is there any easy way to form SQL Query. Take an example,
>
>0x00 means {Order Received}
>0x01 means {Order Approved}
>0x02 means {Order Paid For}
>0x04 means {Order Shipped}
>
>So, the value of '0x03' should represent the first three statuses and '0x07'
>should represent all statuses. If I query for the orders which are approved
>(0x01) and paid for(0x02), the result should also include the records with
>the status 0x07.
>
>What is the best way to query for the BITWISE-OR fields in Oracle other than
>with all possible combinations of ORs?
Take a look at package UTL_RAW, there you'll find functions BIT_AND, BIT_OR, BIT_XOR, BIT_COMPLEMENT,... which all perform bitwise operations on RAW datatypes. If it is not allready installed, you can create the package and it's body by runing utlraw.sql and prvtrawb.plb, located probably in your $RDBMS/admin directory.
>Tx.
>
>-- Ashok
HTH,
-- Jurij Modic <jmodic_at_src.si> Certified Oracle7 DBA (OCP) ================================================ The above opinions are mine and do not represent any official standpoints of my employerReceived on Tue Sep 29 1998 - 11:04:45 CEST
