Received: from meryl.it.uu.se (root@meryl.it.uu.se [130.238.12.42]) by hub.org (8.9.3/8.9.3) with ESMTP id HAA59115 for ; Mon, 31 Jan 2000 07:21:36 -0500 (EST) (envelope-from e99re41@DoCS.UU.SE) Received: from Hund.DoCS.UU.SE (e99re41@Hund.DoCS.UU.SE [130.238.9.89]) by meryl.it.uu.se (8.8.5/8.8.5) with ESMTP id NAA25120; Mon, 31 Jan 2000 13:21:31 +0100 (MET) Received: from localhost (e99re41@localhost) by Hund.DoCS.UU.SE (8.6.12/8.6.12) with SMTP id NAA12794; Mon, 31 Jan 2000 13:21:28 +0100 X-Authentication-Warning: Hund.DoCS.UU.SE: e99re41 owned process doing -bs Date: Mon, 31 Jan 2000 13:21:27 +0100 (MET) From: Peter Eisentraut Reply-To: Peter Eisentraut To: Mark Volpe cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] inet/cidr - can this be done? In-Reply-To: <389337A7.3F02B63B@epamail.epa.gov> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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@gmx.net 75262 Uppsala http://yi.org/peter-e/ Sweden