How do I create a box from fields in a table?

From: Rob Richardson <RDRichardson(at)rad-con(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: How do I create a box from fields in a table?
Date: 2013-10-17 21:04:36
Message-ID: 67D108EDFAD3C148A593E6ED7DCB4BBDC3FB6888@RADCONWIN2K8PDC.radcon.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I need to determine whether a given pair of coordinates is inside a given rectangle. According to the documentation, PostgreSQL provides the box and point types and a "contains" operator that will be perfect for this. However, the example provided in the documentation only shows the creation of boxes and points from constant values. So, the following query works:

select tran_car_identification, box '((0, 1), (2, 3))' from transfer_car

But if I try to use a field from the transfer_car table, it doesn't work:

select tran_car_identification, box '((location, 1), (2, 3))' from transfer_car

That gives me an "invalid input syntax for type box" error.

How do I create a box object using data from the transfer_car table?

Thanks very much!

RobR

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2013-10-17 21:57:44 Re: How do I create a box from fields in a table?
Previous Message Tomas Vondra 2013-10-17 20:40:52 Re: Need some help on Performance 9.0.4