Re: manipulating the POINT data type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: floyds(at)4peakstech(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: manipulating the POINT data type
Date: 2002-08-08 13:35:48
Message-ID: 2702.1028813748@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Floyd Shackelford" <floyds(at)4peakstech(dot)com> writes:
> how do i manipulate the POINT data type in a select statement? how do i
> reference the X and Y portions of the point? for instance, can i select the
> X or Y portion of a POINT?

Yeah, pretend it's an array with indexes 0,1.

regression=# create table p (f1 point);
CREATE TABLE
regression=# insert into p values('(12,34)');
INSERT 437746 1
regression=# select f1[0] from p;
f1
----
12
(1 row)

regression=# select f1[1] from p;
f1
----
34
(1 row)

regression=# update p set f1[1] = 55;
UPDATE 1
regression=# select * from p;
f1
---------
(12,55)
(1 row)

regression=#

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2002-08-08 14:24:17 Re: looking to speed up SELECT ... LEFT JOIN query
Previous Message Oliver Elphick 2002-08-08 13:28:54 Re: getting oid of an INSERT automatically