Santanor Santanor - 2 years ago 133
SQL Question

Binary mask oracle

I have a SQL command in SQL-Server, and I need to migrate it to Oracle, but there's a part of the sql that I don't understand how to translate it. Here's the sql:

select * from myTable where id = @id and (Mask & @Mask) = @Mask

I think that It's a binary mask, but I'm not quite sure and I don't know if I can do that in Oracle, could you help me?

Thank you very much

Answer Source

You are correct - this is binary mask.

Oracle provides only BITAND function, others (BITOR, BITXOR) must be self made.

Using BITAND function this select will return value 2:


So your query in Oracle can be rewritten in following way:

select * from myTable where id = :id and BITAND(Mask, :Mask) = :Mask
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download