Bitwise AND on two variables

Hello all,

We’re using BO 5 and WEBI 2.5 on an Oracle 7.3 database. I want to perform a bitwise AND on a number retrieved from the database. For example: status is retrieved from the database and contains the value 9 (1001b). I want to see whether bit 4 is set. The only solution is to perform a bitwise AND on status: if status AND 8 = true then bit 4 is set. I want to give a variable a value, depending on whether bit 4 is set. We use this type of operators quite often here. Does anybody know how I can solve this? Something like decode(status AND 8,true,‘Ready’,‘NOT Ready’) should work, but the AND operator is not available.

Thanks, Tim Lauret
Tecnomatix Machining Automation
Enschede, the Netherlands


Listserv Archives (BOB member since 2002-06-25)

Use decode(mod(trunc(status/8), 2), 1, ‘Ready’, ‘NOT Ready’).

A Generic formula to get a particular bit value of status field would be:
mod(trunc(status/power(2, )), 2)
where is the bit position starting from right to left with 0.

-Venkat

Hello all,

We’re using BO 5 and WEBI 2.5 on an Oracle 7.3 database. I want to perform a bitwise AND on a number retrieved from the database. For example: status is retrieved from the database and contains the value 9 (1001b). I want to see whether bit 4 is set. The only solution is to perform a bitwise AND on status: if status AND 8 = true then bit 4 is set. I want to give a variable a value, depending on whether bit 4 is set. We use this type of operators quite often here. Does anybody know how I can solve this? Something like decode(status AND 8,true,‘Ready’,‘NOT Ready’) should work, but the AND operator is not available.

Thanks, Tim Lauret
Tecnomatix Machining Automation
Enschede, the Netherlands


Listserv Archives (BOB member since 2002-06-25)