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
Solved

How to use bitand operator?

Posted on 2002-03-05
8
663 Views
Last Modified: 2007-12-19
How can I use bitand so I can turn on TESTING only when the TYPE_NAME is SOFTWARE or S/W REQUEST

SQL> select * from state
  2  ;

   STATEID STATE_NAME    STATE_FOR PB_WEB_VISIBLE_TYPE
---------- -------------------------------- ---------- -------------------
         1 SCHEDULED    0                     0  
         2 DEFERRED     0                      0        
         3 TESTING      0                     0

SQL> select * from type;

    TYPEID TYPE_NAME
---------- --------------------------------
         0 SOFTWARE
         1 S/W REQUEST
         2 SYSTEM
         
Here's an example of what I found.. but I am not sure how to use it...
SQL> select decode(bitand( 24117, power(2,4)), power(2,4), '1', '0') from dual;

DECODE(BITAND(24117,POWER(2,4)
--------------------------------
1


Help please...
Thanks
0
Comment
Question by:sdesar
  • 5
  • 2
8 Comments
 

Author Comment

by:sdesar
ID: 6842895
I think I have to di someting like this-
SQL> select state_name from web_state  where decode(bitand(pb_web_visible_type,  power(2,0)), power(
2,0), 1,0) = 1;

But I get a ....no rows selected... message.



0
 
LVL 22

Expert Comment

by:DrSQL
ID: 6844098
sdesar,
   I'm having some trouble following your request.  Your examples show a bitand on PB_WEB_VISIBLE_TYPE which is 0 in the cases you have (from state).  And the table WEB_STATE isn't described anywhere.  Finally, your follow-up post changes your "power" from 2,4 to 2,0 (or, from 16 to 1).

   Could you try posting your requirement again, or at least more of what your dealing with?  Like, what does it mean to "turn testing on"?

Good luck!
0
 

Author Comment

by:sdesar
ID: 6845003
Oops sorry I meant STATE table.

I want to show STATE 'TESTING only when the TYPE is SOFTWARE or S/W REQUEST
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:sdesar
ID: 6845809

SQL> select * from web_state;

   STATEID STATE_NAME   TYPEID PB_WEB_VISIBLE_TYPE
---------- --------- ---------- -------------------
         1 SCHEDULED       0                   0
         2 DEFERRED        0                   0
         3 TESTING         0                   0
         5 CLOSED          0                   0
         2 DEFERRED        1                   0
         3 TESTING         1                   0
         5 CLOSED          1                   0
         0 OPEN            1                   0
         5 CLOSED          2                   0
Currently, web_state is a lookup table and I can tell what TYPES have what STATES.

Thefore, question is how can I use the 'bitand' to display only TESTING if 'TYPEID' is 0 or 1 ie software or software request.

I need to know what kind of select shold I use so I can modifiy the JSP to show only TESTING if type is 0 or 1.

I hope this clarifies it a bit.
Awaiting suggestions.
Thanks
0
 
LVL 22

Accepted Solution

by:
DrSQL earned 50 total points
ID: 6847274
sdesar,
   I'm not sure why you believe that the bitand is the answer.  To get a list of all of the web_state entries showing TESTING whenever it's a TYPEID of 0 or 1:


1) Assume there IS a "state" table and you want no cheating by using what's in web_state:

select w.stateid,w.state_name,w.typeid,w.PB_WEB_VISIBLE_TYPE,
s.STATE_NAME STATE_SETTING
  from web_state w, states s
 where s.stateid = decode(w.typeid,0,3,1,3,w.STATEID);

2) Assume there is no "state" table and you just want to override the state_name column value:

select stateid,state_name,typeid,PB_WEB_VISIBLE_TYPE,
       decode(w.typeid,0,'TESTING',1,'TESTING',
                                STATE_NAME) STATE_SETTING
  from web_state;

3) If you want to actually CHANGE the state in the table:

update web_state set stateid=3, state_name='TESTING'
 where typeid in (0,1);

I still don't feel like I know what you're trying to do (other than use bitand).  The relational design is a little confusing (do you have state_name in two tables, or one) and I'm not sure what the JSP is trying do do, but the first two selects will do what you asked.  Post again if this is still missing the point.

Good luck!
0
 

Author Comment

by:sdesar
ID: 6851747
I have a jsp that that a TYPE comboBox... this lists only SOFTWARE, S/W REQUEST, SYSTEM.

I want the STATE combox to display - OPEN, TESTING, CLOSED only if the TYPE is SOFTWARE or S/W REQUEST.  
else
display only OPEN CLOSED.

When I enter this JSP I know the TYPE of ticket it is .. ie SOFTWARE or S/W REQUEST or SYSTEM

therefore instead of hardcoding the logic in the jsp.. I am wondering how and if I can use the bitand operator to set the bits to true, false.

Thanks
0
 
LVL 2

Expert Comment

by:ddandekar
ID: 6885109
You can check asktom.com site.
There is an example of bitand operator.
0
 

Author Comment

by:sdesar
ID: 6891308
Awesome Thanks!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
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
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

791 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