Today i faced a situation when i need to do binary operations in Oracle Query. I had no idea how to do it. Obviously Googling worked as always. :-) :-) . Below was the problem:
I need to apply AND operation on a hexadecimal number as below but following query did not work.
select <num> & 0xf from dual;
I found that BITAND function will do this task, so i chnaged above query to as below and it worked.
select BITAND(<num>, 15)+0 from dual;
(here 15 is equivalent to 0xf, Note that BITAND returns a binary integer, so to use it in SQL you will need to convert it to a numeric.)
Similarly, Oracle has BITOR function for OR operation.
Thursday, November 6, 2008
Oracle: Binary operations
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment