From: Aditya <aditya@grot.org>
To: pgsql-sql@postgresql.org
Subject: converting from bigint to bit to use bitwise operators
Date: Fri, 18 Apr 2003 12:11:23 -0700
Message-ID: <20030418191123.GA44801@mighty.grot.org> (raw)
For historical reasons, I have IPv4 addresses stored as bigint and I would
like to convert them to dot-quad (ie. A.B.C.D) in a select. This is how I
would normally do it:
- remotehost is the IP address as a bigint
select
((remotehost::bit varying(32) >> 24) & 11111111) || '.' ||
((remotehost::bit varying(32) & 11111100) >> 16) || '.' ||
((remotehost::bit varying(32) & 11110000) >> 8) || '.' ||
((remotehost::bit varying(32) & 11000000)) as ip,
httpquery
from
weblogs
;
however this complains:
ERROR: Cannot cast type 'bigint' to 'bit varying'
hints?
Thanks,
Adi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: aditya@grot.org
Subject: Re: converting from bigint to bit to use bitwise operators
In-Reply-To: <20030418191123.GA44801@mighty.grot.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox