Re: BITWISE AND

From: Martin Farber <farber_at_nynexst.com>
Date: 22 Feb 1995 14:30:27 GMT
Message-ID: <3ifhq3$o9r_at_news.nynexst.com>


In article e15_at_pheidippides.axion.bt.co.uk, Karl Zdero <karlz_at_pst.bt.co.uk> () writes:
>I have a conversion task to perform. One of the fields contains a
>series of 1's and 0's ie: 10011011.
>
>This field represents a number of flags that are turned on!
>
>Now, I could store this field as a numeric column (in this case the
>value would be 155 as bitpos 1,4,5,7 and 8 are turned on.
>
>How would I in SQL, determine which flags are turned on in a SELECT
>statement?
>
>Something along the lines of a BITWISE AND operation.
>ie: To determine if flag number 4 is turned on I would AND the colums
> value with 4 and test the result is 4.
>
>As far as I know, BITWISE ops are not possible in SQL.

There is an undocumented bitand() function in Oracle's SQL. I don't know how long it'll be around, but as of 7.1.4 it still works.

For that matter, in 7.1.4 you could write your own functions and call them in SQL statements!

Good luck!

Sincerely,

Martin Farber
Independent Oracle Consultant "A Jack of all trades and a slave to one."

                        |  NYNEX Science & Technology
                        |  500 Westchester Ave, Rm 1B-23
                        |  White Plains, NY  10604
                        |     -----------------
                        |  email: farber_at_nynexst.com
                        |  Voice: 914/644-2656
                        |    FAX: 914/644-2216
Received on Wed Feb 22 1995 - 15:30:27 CET

Original text of this message