How do I convert four table columns into a box?

From: Rob Richardson <RDRichardson(at)rad-con(dot)com>
To: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: How do I convert four table columns into a box?
Date: 2012-07-17 14:29:17
Message-ID: 67D108EDFAD3C148A593E6ED7DCB4BBD1FDB6569@RADCONWIN2K8PDC.radcon.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have the following table:

CREATE TABLE operationsplanning.shop_floor
(
id bigserial NOT NULL,
location_id character varying(32),
area_top integer NOT NULL,
area_bottom integer NOT NULL,
area_left integer NOT NULL,
area_right integer NOT NULL,
CONSTRAINT shop_floor_pkey PRIMARY KEY (id)
)

I would like to be able to tell which row in this table describes a rectangle that contains a given point. So, I figured I'd convert the four integers into a box. However, I don't know how to do it. The documentation only shows how to work with literals, like this:
Box '((0, 0), (1, 1))'
But this does not work:
Select box '((area_left, area_top), (area_right, area_bottom))' from operationsplanning.shop_floor

I tried a more normal cast syntax:
select location_id, ((area_left, area_top),(area_right, area_bottom))::box from operationsplanning.shop_floor

But PostgreSQL complained that it could not cast an object of type record to type box.

How do I do this?

Thanks very much!

RobR

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Rob Richardson 2012-07-17 15:12:59 Re: How do I convert four table columns into a box?
Previous Message Tom Lane 2012-07-17 02:28:04 Re: Smallint needs explicit cast in psql?