?
Solved

what's the meaning of ampersand in select case statement

Posted on 2011-09-29
9
Medium Priority
?
909 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
[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
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 504 total points
ID: 36813581
<% 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 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 500 total points
ID: 36813594
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
ID: 36813625
so, you say....

it compare (sysstat2 == 32768) OR (57344 == 32768) ??
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 504 total points
ID: 36813649
yes
0
 
LVL 143

Assisted Solution

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

Assisted Solution

by:maneksh
maneksh earned 744 total points
ID: 36814235
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 744 total points
ID: 36814350
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 744 total points
ID: 36814459
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 252 total points
ID: 36816459
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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…
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
Suggested Courses

764 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