pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedExtracting single coordinate from a box
4+ messages / 3 participants
[nested] [flat]
* Extracting single coordinate from a box
@ 2003-08-28 16:40 Donald Fraser <demolish@cwgsy.net>
2003-08-28 16:55 ` Re: Extracting single coordinate from a box Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Donald Fraser @ 2003-08-28 16:40 UTC (permalink / raw)
To: pgsql-admin
I'm wondering if anyone knows how to extract a single co-ordinate from the data
type "box".
I know that I can access a single co-ordinate from a "point" using the array
notation: p[0] or p[1] where p is of type "point".
I can extract a single "point" from a "box" with b[0] or b[1] where b is of
type "box".
But when I try something like b[0][0] the passer ignores the second array
subscript parameter and returns only a "point".
Many thanks in advance,
Donald Fraser.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Extracting single coordinate from a box
2003-08-28 16:40 Extracting single coordinate from a box Donald Fraser <demolish@cwgsy.net>
@ 2003-08-28 16:55 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-08-28 17:12 ` Re: Extracting single coordinate from a box Donald Fraser <demolish@cwgsy.net>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2003-08-28 16:55 UTC (permalink / raw)
To: Donald Fraser <demolish@cwgsy.net>; +Cc: pgsql-admin
"Donald Fraser" <demolish@cwgsy.net> writes:
> But when I try something like b[0][0] the passer ignores the second array
> subscript parameter and returns only a "point".
Try this:
regression=# select f1, (f1[1])[0] from box_tbl;
f1 | f1
---------------------+-----
(2,2),(0,0) | 0
(3,3),(1,1) | 1
(2.5,3.5),(2.5,2.5) | 2.5
(3,3),(3,3) | 3
(4 rows)
You need the extra parentheses because the two subscript operations need
to work on fundamentally different datatypes --- if you write f1[1][0]
you are asking to subscript a 2-D array which this isn't.
[ experiments further ... ] Drat, seems that syntax works in 7.4 but
not 7.3. Dunno if that will help you.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Extracting single coordinate from a box
2003-08-28 16:40 Extracting single coordinate from a box Donald Fraser <demolish@cwgsy.net>
2003-08-28 16:55 ` Re: Extracting single coordinate from a box Tom Lane <tgl@sss.pgh.pa.us>
@ 2003-08-28 17:12 ` Donald Fraser <demolish@cwgsy.net>
2003-08-28 17:57 ` Re: Extracting single coordinate from a box Jean-Luc Lachance <jllachan@nsd.ca>
0 siblings, 1 reply; 4+ messages in thread
From: Donald Fraser @ 2003-08-28 17:12 UTC (permalink / raw)
To: pgsql-admin
Thanks for the quick response.
----- Original Message -----
> "Donald Fraser" <demolish@cwgsy.net> writes:
> > But when I try something like b[0][0] the passer ignores the second array
> > subscript parameter and returns only a "point".
> You need the extra parentheses because the two subscript operations need
> to work on fundamentally different datatypes --- if you write f1[1][0]
> you are asking to subscript a 2-D array which this isn't.
>
> [ experiments further ... ] Drat, seems that syntax works in 7.4 but
> not 7.3. Dunno if that will help you.
I'm using 7.3.4 at the moment and I tried the scenario of using parentheses,
which didn't work.
I wrote a function in the end to extract it, but it would have been more
elegant without it :-(
Thanks again
Donald
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Extracting single coordinate from a box
2003-08-28 16:40 Extracting single coordinate from a box Donald Fraser <demolish@cwgsy.net>
2003-08-28 16:55 ` Re: Extracting single coordinate from a box Tom Lane <tgl@sss.pgh.pa.us>
2003-08-28 17:12 ` Re: Extracting single coordinate from a box Donald Fraser <demolish@cwgsy.net>
@ 2003-08-28 17:57 ` Jean-Luc Lachance <jllachan@nsd.ca>
0 siblings, 0 replies; 4+ messages in thread
From: Jean-Luc Lachance @ 2003-08-28 17:57 UTC (permalink / raw)
To: Donald Fraser <demolish@cwgsy.net>; +Cc: pgsql-admin
I think you are forgetting that a box is an array of one dimension with
two points.
So, the first point is B[0] and the second is B[1].
Donald Fraser wrote:
>
> Thanks for the quick response.
>
> ----- Original Message -----
> > "Donald Fraser" <demolish@cwgsy.net> writes:
> > > But when I try something like b[0][0] the passer ignores the second array
> > > subscript parameter and returns only a "point".
>
> > You need the extra parentheses because the two subscript operations need
> > to work on fundamentally different datatypes --- if you write f1[1][0]
> > you are asking to subscript a 2-D array which this isn't.
> >
> > [ experiments further ... ] Drat, seems that syntax works in 7.4 but
> > not 7.3. Dunno if that will help you.
>
> I'm using 7.3.4 at the moment and I tried the scenario of using parentheses,
> which didn't work.
> I wrote a function in the end to extract it, but it would have been more
> elegant without it :-(
>
> Thanks again
> Donald
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2003-08-28 17:57 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-08-28 16:40 Extracting single coordinate from a box Donald Fraser <demolish@cwgsy.net>
2003-08-28 16:55 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-08-28 17:12 ` Donald Fraser <demolish@cwgsy.net>
2003-08-28 17:57 ` Jean-Luc Lachance <jllachan@nsd.ca>
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