Skip site navigation (1) Skip section navigation (2)

PostgreSQL and Bitwise and with int8 field

From: "Seader, Cameron" <CSeader(at)idahopower(dot)com>
To: pgsql-php(at)postgresql(dot)org
Subject: PostgreSQL and Bitwise and with int8 field
Date: 2003-12-20 21:44:31
Message-ID: 71B8A8BEC516CF46835CA629156CF211103813@bedford.idacorp.local (view raw or flat)
Thread:
Lists: 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 LIMIT 1

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 in an int8 field.
When changed to binary it should read 100000000000000000000000000000000001000000 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 read 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 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 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 wrong to get this to work?
Thanks,

Cameron Seader
Operations Center Technician II
CSeader(at)Idahopower(dot)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 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 received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. A1.



Responses

pgsql-php by date

Next:From: Michael FuhrDate: 2003-12-21 01:52:49
Subject: Re: PostgreSQL and Bitwise and with int8 field
Previous:From: ljbDate: 2003-12-20 02:24:34
Subject: How to cancel a query when user stops a page load

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group