| From: | Randall Lucas <rlucas(at)tercent(dot)net> |
|---|---|
| To: | Aditya <aditya(at)grot(dot)org> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: converting from bigint to bit to use bitwise operators |
| Date: | 2003-04-21 21:55:14 |
| Message-ID: | EE830E7A-7443-11D7-A502-000A957653D6@tercent.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Adi,
Try an explicit cast into a text type and then into a bit string type.
Best,
Randall
On Monday, April 21, 2003, at 05:50 PM, Aditya wrote:
> 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 (the remotehost column 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
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Mario Alberto Soto Cordones | 2003-04-21 21:58:38 | Re: PROBLEM WITH FUNCTIONS |
| Previous Message | Aditya | 2003-04-21 21:50:20 | converting from bigint to bit to use bitwise operators |