Solved

How to use bitand operator?

Posted on 2002-03-05
8
666 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
[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
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
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.  …
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

739 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