Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id UAA18671 for ; Thu, 20 Jan 2000 20:22:21 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id UAA25695; Thu, 20 Jan 2000 20:22:02 -0500 (EST) To: mpg4@duluoz.net cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] Geometric types in SELECT? In-reply-to: <20000120135250.7541.qmail@paradise.duluoz.net> References: <20000120135250.7541.qmail@paradise.duluoz.net> Comments: In-reply-to mpg4@duluoz.net message dated "Thu, 20 Jan 2000 05:52:50 -0800" Date: Thu, 20 Jan 2000 20:22:02 -0500 Message-ID: <25692.948417722@sss.pgh.pa.us> From: Tom Lane mpg4@duluoz.net writes: > =>select length( '((0,0),coord)'::lseg ) from address; > I receive this error: > Bad lseg external representation '((0,0), coord)' > If I replace coord with an actual value, I don't get the error. Am I > somehow mangling the syntax? Yup. '((0,0),coord)'::lseg is a literal constant --- in general, 'anything'::typename is a literal constant in Postgres. And it's not a valid literal constant for lseg. I suppose coord is the name of a point column in your table? To do it correctly, you'd need something like select length( makelseg( '(0,0)'::point, coord )) from table; I'm not sure if there is a function that makes an lseg from two points, and if there is it probably isn't called "makelseg", but hopefully you get the idea. I am pretty sure there is a function that computes the distance between two points, so what you are likely to end up really writing is select distance( '(0,0)'::point, coord ) from table; (after you dig through the documentation to find the actual name of that function...) regards, tom lane