PostgreSQL and Bitwise and with int8 field - Mailing list pgsql-php

From Seader, Cameron
Subject PostgreSQL and Bitwise and with int8 field
Date
Msg-id 71B8A8BEC516CF46835CA629156CF211103813@bedford.idacorp.local
Whole thread Raw
Responses Re: PostgreSQL and Bitwise and with int8 field  (Michael Fuhr <mfuhr+pgsql-php@fuhr.org>)
List pgsql-php
I 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
LIMIT1 

im splitting this 64 bit integer into two 32 bit integers so that PHP can handle it.

if the highalarm value is 20000000040, which was inputed as a hex value chopping off the 0x at the beginning to store
inan int8 field. 
When changed to binary it should read 100000000000000000000000000000000001000000 which is a 64 bit binary value. from
theselect statement above, what i am trying to acheive is splitting this 64 bit binary up so that i can read it in two
32bit 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
startingfrom right to left right being 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 point 42. so when reading it in PHP i can tell
thatpoint 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
thisbinary going from right to left. 

Can i please get some help with this SQL Statement - am i doing something wrong 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
applicablelaw. If you are not the intended recipient, you are hereby notified that any disclosure, copying,
distribution,or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you
receivedthis transmission in error, please immediately contact the sender and destroy the material in its entirety,
whetherin electronic or hard copy format. Thank you. A1. 



pgsql-php by date:

Previous
From: ljb
Date:
Subject: How to cancel a query when user stops a page load
Next
From: Michael Fuhr
Date:
Subject: Re: PostgreSQL and Bitwise and with int8 field