Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Bit Function
In article <9bhd00$moc$1_at_news.att.net.il>, Dudi Naim <yoramn_at_cti2.com>
writes:
>Hi all
>
>How can I do bit function (like or xor and) between 2 numbers in PLSQL ?
>
>thanks
>
>yoramn_at_cti2.com
>
>
I believe that the bitand function is now listed in the SQL manual. If not
Oracle has published queries using the function in the OPS Concepts manual.
Here is some code I saved off a post in the past. I have not tested it nor did I verify the url is still valid:
http://www.oradba.freeserve.co.uk/tips/bitwise_ops.htm
CREATE OR replace FUNCTION bitor( x IN NUMBER, y IN NUMBER ) RETURN NUMBER
AS
BEGIN
RETURN x + y - bitand(x,y);
END;
/
CREATE OR replace FUNCTION bitxor( x IN NUMBER, y IN NUMBER ) RETURN NUMBER
AS
BEGIN
RETURN bitor(x,y) - bitand(x,y);
END;