Greetings,

Considering that this can be done:

network=# SELECT '0.0.0.0'::inet + 702545920;
  ?column?
------------
 41.224.0.0
(1 row)

How can I perform an operation similar to this that works?

network=# select case when '41.224.0.0'::inet = 702545920 then true else false 
end;
ERROR:  operator does not exist: inet = integer
LINE 1: select case when '41.224.0.0'::inet = 702545920 then true el...
                                            ^
HINT:  No operator matches the given name and argument type(s). You might need 
to add explicit type casts.

network=# select case when '41.224.0.0'::inet = 702545920::inet then true else 
false end;
ERROR:  cannot cast type integer to inet
LINE 1: select case when '41.224.0.0'::inet = 702545920::inet then t...

I'm guessing that there is some internal postgres function that performs the 
integer to IP address conversion in the first example, but I am at a loss to 
identify it.

The reason I ask for this is that we have a dataset that contains ranges of IP 
addresses, associated with countries, where the addresses are represented as 
integers (bigints).

Thanks for the pointer.

Bill MacArthur

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Reply via email to