Link to home
Start Free TrialLog in
Avatar of sdesar
sdesar

asked on

How to use bitand operator?

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
Avatar of sdesar
sdesar

ASKER

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.



Avatar of DrSQL - Scott Anderson
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!
Avatar of sdesar

ASKER

Oops sorry I meant STATE table.

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

ASKER


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
ASKER CERTIFIED SOLUTION
Avatar of DrSQL - Scott Anderson
DrSQL - Scott Anderson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sdesar

ASKER

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
You can check asktom.com site.
There is an example of bitand operator.
Avatar of sdesar

ASKER

Awesome Thanks!