Solved

what's the meaning of ampersand in select case statement

Posted on 2011-09-29
9
855 Views
Last Modified: 2012-05-12
select name,
       case sysstat2 & 57344
            when 32768 then "datarows"

What's the meaning of the ampersand in front of '57344'

Thanks in advance
0
Comment
Question by:gamjaradio
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 126 total points
Comment Utility
<% dim iRow
select name,
       case sysstat2 & 57344
            when 32768 then "datarows"

Meaning of this

sysstat2 & 57344   , one of this value either field value of sysstat2 or 57344  is equal to 32768  then "datarows"

in other words condition looks like this

if (sysstat2 = 32768) Or (57344 = 32768 ) then "datarows"
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 125 total points
Comment Utility
actually,
 case sysstat2 & 57344

is doing a bitwise AND of the 2 values (aka the variable sysstat2 and 57344).
this value will then be compared to the value 32768 , if that matches ....

hope this helps
0
 

Author Comment

by:gamjaradio
Comment Utility
so, you say....

it compare (sysstat2 == 32768) OR (57344 == 32768) ??
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 126 total points
Comment Utility
yes
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 125 total points
Comment Utility
as posted above, I have to disagree ...
0
 
LVL 2

Assisted Solution

by:maneksh
maneksh earned 186 total points
Comment Utility
Hi,

I am afraid Pratima is wrong.

& is a bitwise operator. it converts the operands into binary and evaluates column by column.

Please follow the link to see details

http://manuals.sybase.com/onlinebooks/group-as/asg1250e/sqlug/@Generic__BookTextView/1719;pt=945

Maneksh

0
 
LVL 2

Assisted Solution

by:maneksh
maneksh earned 186 total points
Comment Utility
Here in your example 57344 is 1110000000000000
and 32768 is 1000000000000000

some examples of  Values of  sysstat2  that could satisfy the condition are
40959  and  32768

Hope this helps

Maneksh
0
 
LVL 2

Assisted Solution

by:maneksh
maneksh earned 186 total points
Comment Utility
Hi,

Looking at your query I think you are looking for the lock scheme of a table  which is maitained in sysstat2 table in bit representation.Bit corresponding to 8192 , 16384 and 32768 represents the lock schema and 57344 is the sum of these 3.


Hope I dint confuse

maneksh


0
 
LVL 50

Assisted Solution

by:Lowfatspread
Lowfatspread earned 63 total points
Comment Utility
its a bitwise operator signifying a logical and operation is performed on the bit patterns of the two expressions

from

msdn
The bitwise & operator performs a bitwise logical AND between the two expressions, taking each corresponding bit for both expressions. The bits in the result are set to 1 if and only if both bits (for the current bit being resolved) in the input expressions have a value of 1; otherwise, the bit in the result is set to 0.

so basically when dealing with flags/indicators stored as a pattern of bits and you wish to test for some specific values
you calculate the numeric value of the combination that you are interested in and have that logically anded with the total option value...

you can then easier test the result to see if the desired set of conditions is present.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
c# code 19 56
Insert from Stored Procedure where some field/s > 0 7 32
report returning null 21 49
How to query date ranges with SQL 6 22
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…
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 video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

772 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

11 Experts available now in Live!

Get 1:1 Help Now