Re: manipulating the POINT data type - Mailing list pgsql-sql

From Tom Lane
Subject Re: manipulating the POINT data type
Date
Msg-id 2702.1028813748@sss.pgh.pa.us
Whole thread Raw
In response to manipulating the POINT data type  ("Floyd Shackelford" <floyds@4peakstech.com>)
List pgsql-sql
"Floyd Shackelford" <floyds@4peakstech.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


pgsql-sql by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: getting oid of an INSERT automatically
Next
From: Richard Huxton
Date:
Subject: Re: [GENERAL] looking to speed up SELECT ... LEFT JOIN query