Re: bitwise operators ?

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: 2000/02/29
Message-ID: <38BBAB19.604C_at_yahoo.com>#1/1


Mathieu Legare wrote:
>
> Hi,
>
> I am using oracle 8.0.5 and pro*c 8.0.5.0.0 on AIX 4.2.1
> and I was wondering if it's possible to do bitwise
> operations on a NUMBER field of an oracle database.
>
> I am converting a C program that was using bitwise operators
> to manages some IDs.
>
> #define ID_active = 0x00000001
> #define ID_sleep = 0x00000002
> #define ID_dead = 0x00000004
> ...
> if((user.id & (ID_sleep | ID_dead)) == (ID_sleep | ID_dead))
> {
> ...
> }
>
> Is there any operators or a way to do it with an SQL statement ?
> Is it possible to do bitwise AND or bitwise OR in oracle sql ?
> I know I can make a loop with a cursor and do this in C but
> it would probably be faster if I could do it in a single
> SQL statement
>
> Thanks and have a nice day,
> --
> Mathieu Legare
> Analyste en informatique (systeme/webmestre)
> Service de l'informatique
> Universite du Quebec a Trois-Rivieres
> Email : Mathieu_Legare_at_uqtr.uquebec.ca
> Tel : 376-5011 x2439
> --

You can do it via PL/SQL and then call these functions from your SQL.

http://www.oracledba.co.uk/tips/bitwise_ops.htm

HTH

-- 
===========================================
Connor McDonald
http://www.oracledba.co.uk

We are born naked, wet and hungry...then things get worse
Received on Tue Feb 29 2000 - 00:00:00 CET

Original text of this message