pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: floyds@4peakstech.com
Cc: pgsql-sql@postgresql.org
Subject: Re: manipulating the POINT data type
Date: Thu, 08 Aug 2002 09:35:48 -0400
Message-ID: <2702.1028813748@sss.pgh.pa.us> (raw)
In-Reply-To: <NDBBKEGJICMIMJHJEBCOIEDIFHAA.floyds@4peakstech.com>
References: <NDBBKEGJICMIMJHJEBCOIEDIFHAA.floyds@4peakstech.com>

"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



view thread (2+ messages)

Message-ID: <2702.1028813748@sss.pgh.pa.us>
Permalink:  ../2702.1028813748@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2702.1028813748@sss.pgh.pa.us

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, floyds@4peakstech.com
  Subject: Re: manipulating the POINT data type
  In-Reply-To: <2702.1028813748@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