How do I convert four table columns into a box? - Mailing list pgsql-novice

From Rob Richardson
Subject How do I convert four table columns into a box?
Date
Msg-id 67D108EDFAD3C148A593E6ED7DCB4BBD1FDB6569@RADCONWIN2K8PDC.radcon.local
Whole thread Raw
Responses Re: How do I convert four table columns into a box?  (Rob Richardson <RDRichardson@rad-con.com>)
List 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

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Smallint needs explicit cast in psql?
Next
From: Rob Richardson
Date:
Subject: Re: How do I convert four table columns into a box?