How do I convert four table columns into a box?

Поиск
Список
Период
Сортировка
От Rob Richardson
Тема How do I convert four table columns into a box?
Дата
Msg-id 67D108EDFAD3C148A593E6ED7DCB4BBD1FDB6569@RADCONWIN2K8PDC.radcon.local
обсуждение исходный текст
Ответы Re: How do I convert four table columns into a box?  (Rob Richardson <RDRichardson@rad-con.com>)
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Smallint needs explicit cast in psql?
Следующее
От: Rob Richardson
Дата:
Сообщение: Re: How do I convert four table columns into a box?