Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Logical OR testing

Re: Logical OR testing

From: Malcolm Dew-Jones <yf110_at_vtn1.victoria.tc.ca>
Date: 2 Feb 2000 11:13:19 -0800
Message-ID: <389881cf@news.victoria.tc.ca>


eteckard_at_yahoo.com wrote:
: Does anyone know the proper syntax (if you can even do it at all) for
: doing bitwise logical AND testing within the WHERE clause of a SQL
: statement on Oracle?

: Here's Microsoft's documentation on how to do it in SQL Server...

: http://msdn.microsoft.com/library/psdk/sql/operator_9.htm

: ...but I can't find any Oracle documentation on how to accomplish the
: same task on Oracle.

: For example, here's a snip of a procedure I wrote for SQL Server...

: -----
: if (@iStatusLong & 32) > 0
: begin
: /*
: do something...
: */
: end
: -----

the bitwise test is equivalent to an arithmetic compare, though it may be more complex.

to tranform

        istatuslong & 32

notice that 32 = (binary) 100000

so the bitwise test is true when ever istatuslong has the 6th bit set.

Something like the following will work, though I would diagram the bit patterns to check my answer as I could be off by some power of 2 in the constants.

WHERE ((istatuslong MOD 64) - (istatuslong MOD 32) ) = 32

MOD 64 gets the bottom 6 bits
MOD 32 gets the bottom 5 bits
the bottom 5 bits will be the same number for both calculations, therefore substracting leaves just the 6th bit, and its value is 32 if it's set.

: Anybody?

: Tom

: Sent via Deja.com http://www.deja.com/
: Before you buy.

-- Received on Wed Feb 02 2000 - 13:13:19 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US