Solved

How to use bitand operator?

Posted on 2002-03-05
8
657 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
Comment Utility
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
Comment Utility
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
Comment Utility
Oops sorry I meant STATE table.

I want to show STATE 'TESTING only when the TYPE is SOFTWARE or S/W REQUEST
0
 

Author Comment

by:sdesar
Comment Utility

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
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.

 
LVL 22

Accepted Solution

by:
DrSQL earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
You can check asktom.com site.
There is an example of bitand operator.
0
 

Author Comment

by:sdesar
Comment Utility
Awesome Thanks!
0

Featured Post

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.

Join & Write a Comment

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now