From: Tom Lane <tgl@sss.pgh.pa.us>
To: mpg4@duluoz.net
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Geometric types in SELECT?
Date: Thu, 20 Jan 2000 20:22:02 -0500
Message-ID: <25692.948417722@sss.pgh.pa.us> (raw)
In-Reply-To: <20000120135250.7541.qmail@paradise.duluoz.net>
References: <20000120135250.7541.qmail@paradise.duluoz.net>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, mpg4@duluoz.net
Subject: Re: [SQL] Geometric types in SELECT?
In-Reply-To: <25692.948417722@sss.pgh.pa.us>
References: <20000120135250.7541.qmail@paradise.duluoz.net> <25692.948417722@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox