Re: [SQL] inet/cidr - can this be done?

From: Peter Eisentraut <e99re41(at)DoCS(dot)UU(dot)SE>
To: Mark Volpe <volpe(dot)mark(at)epamail(dot)epa(dot)gov>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] inet/cidr - can this be done?
Date: 2000-01-31 12:21:27
Message-ID: Pine.GSO.4.02A.10001311317150.12762-100000@Hund.DoCS.UU.SE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

The problem is that host(ip)||'/24' isn't of the inet type, it's text. For
a simple select query you don't have to cast this at all, it would seem,
since it goes as text to the frontend either way.

Also, a straightforward cast inet_value::cidr seems to work for me.

On Sat, 29 Jan 2000, Mark Volpe wrote:

> Is there a way to convert inet types
> to cidr? I have a table with an inet
> field, and it would be cool to, say,
> group by class C network. My little attempt
> here results in an error:
>
> CREATE TABLE test(ip inet);
> INSERT INTO test VALUES('192.168.1.2');
> SELECT (host(ip) || '/24')::cidr FROM test;
>
> ERROR: No such function 'cidr' with the specified attributes
>
> Thanks in advance
> - Mark
>
> ************
>
>

--
Peter Eisentraut Sernanders vaeg 10:115
peter_e(at)gmx(dot)net 75262 Uppsala
http://yi.org/peter-e/ Sweden

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Marc Tardif 2000-01-31 16:59:19 now() returning int4
Previous Message Jan Wieck 2000-01-31 09:49:52 Re: [HACKERS] Help with pl/pgsql, triggers, and foreign keys