Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Bitwise operator in Oracle

Posted on 2000-04-02
4
Medium Priority
?
1,094 Views
Last Modified: 2012-08-14
I'm porting stored procedures from Sybase to Oracle 8i but I can't find any bitwise operator in Oracle. Is there any? If not please give me a way to do it (AND, OR, XOR, NOT operators).
0
Comment
Question by:daitt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:sudhi022299
ID: 2678893
In Oracle AND, OR and NOT operators are supported. XOR could be implemented i think.
0
 
LVL 3

Author Comment

by:daitt
ID: 2679031
Please give me a simple example of using them in a Stored Procedure.
Just print out (5 AND 7) for example.
Thanks
0
 
LVL 4

Accepted Solution

by:
syakobson earned 200 total points
ID: 2680342
sudhi,
AND, OR and NOT are LOGICAL not BITWISE operators. They take TRUE/FALSE operands only. PL/SQL provides UTL_RAW package which will allow you to perform BITWISE operations against either raw datatype or strings assigned HEX values:

SQL> declare a varchar2(2);
  2  b varchar2(2);
  3  begin
  4  a := '&1';
  5  b := '&2';
  6  dbms_output.put_line(a || ' AND ' || b || ' = ' || utl_raw.bit_and(a,b));
  7  dbms_output.put_line(a || ' OR  ' || b || ' = ' || utl_raw.bit_or(a,b));
  8  dbms_output.put_line(a || ' XOR  ' || b || ' = ' || utl_raw.bit_xor(a,b));
  9  dbms_output.put_line('NOT ' || a || ' = ' || utl_raw.bit_complement(a));
 10  end;
 11  /
Enter value for 1: 1F
old   4: a := '&1';
new   4: a := '1F';
Enter value for 2: F1
old   5: b := '&2';
new   5: b := 'F1';
1F AND F1 = 11
1F OR  F1 = FF
1F XOR  F1 = EE
NOT 1F = E0

PL/SQL procedure successfully completed.

Solomon Yakobson.
0
 
LVL 4

Expert Comment

by:sudhi022299
ID: 2680578
Sorry Solomon, i didn't read the question properly. But thanks for the UTL_RAW package though.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example, show how to take different types of Oracle backups using RMAN.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question