Обсуждение: manipulating the POINT data type

Поиск
Список
Период
Сортировка

manipulating the POINT data type

От
"Floyd Shackelford"
Дата:
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? can i do something like "select pointa.x" or
"where pointa.x = pointb.x"?

When using JDBC, when i get a POINT value from a result set, what am i
getting? a java.awt.Point or a string?

Regards,

Floyd Shackelford
4 Peaks Technology Group, Inc.
VOICE: 334.735.9428
FAX:   916.404.7125
EMAIL: FloydS@4PeaksTech.com
ICQ #: 161371538
acta non verba



Re: manipulating the POINT data type

От
Tom Lane
Дата:
"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