• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 938
  • Last Modified:

what's the meaning of ampersand in select case statement

select name,
       case sysstat2 & 57344
            when 32768 then "datarows"

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

Thanks in advance
0
gamjaradio
Asked:
gamjaradio
  • 3
  • 2
  • 2
  • +2
8 Solutions
 
Pratima PharandeCommented:
<% 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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
gamjaradioAuthor Commented:
so, you say....

it compare (sysstat2 == 32768) OR (57344 == 32768) ??
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
Pratima PharandeCommented:
yes
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
as posted above, I have to disagree ...
0
 
manekshCommented:
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
 
manekshCommented:
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
 
manekshCommented:
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
 
LowfatspreadCommented:
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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now