PostgreSQL and Bitwise and with int8 field
am 20.12.2003 22:44:31 von CSeaderI am trying to get the proper output with this SQL statement:
SELECT *, (highalarm & 0xffffffff)as high1, (highalarm >> 32)as high2 FROM =
t444d500009b5_2_6 ORDER BY utctime DESC LIMIT 1
im splitting this 64 bit integer into two 32 bit integers so that PHP can h=
andle it.=20
if the highalarm value is 20000000040, which was inputed as a hex value cho=
pping off the 0x at the beginning to store in an int8 field.
When changed to binary it should read 1000000000000000000000000000000000010=
00000 which is a 64 bit binary value. from the select statement above, what=
i am trying to acheive is splitting this 64 bit binary up so that i can re=
ad it in two 32 bit values so that PHP can handle it.
when in the 64 bit binary value i use this value to determine error points =
for a device, which has 42 data points starting from right to left right be=
ing the start of point 1 and left ending in point 42 unless it is 0 it will=
truncate. to the closest 1 if there is one. This example happens to be poi=
nt 42. so when reading it in PHP i can tell that point 42 is in alarm or in=
some kind of bad status and also point 7 is as well since there is a 1 in =
the 7 spot of this binary going from right to left.
Can i please get some help with this SQL Statement - am i doing something w=
rong to get this to work?
Thanks,
Cameron Seader
Operations Center Technician II
CSeader@Idahopower.com
1.208.388.2582 Office
This transmission may contain information that is privileged, confidential =
and/or exempt from disclosure under applicable law. If you are not the inte=
nded recipient, you are hereby notified that any disclosure, copying, distr=
ibution, or use of the information contained herein (including any reliance=
thereon) is STRICTLY PROHIBITED. If you received this transmission in erro=
r, please immediately contact the sender and destroy the material in its en=
tirety, whether in electronic or hard copy format. Thank you. A1.
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster