Re: Create View from command line

From: Andy Colson <andy(at)squeakycode(dot)net>
To: OisinJK <oisin(dot)kelly(at)landscapeplanning(dot)co(dot)uk>, PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Create View from command line
Date: 2010-05-10 13:56:08
Message-ID: 4BE81078.80900@squeakycode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 5/10/2010 4:43 AM, OisinJK wrote:
> Hi
>
> I’m trying to build a Windows Form application that needs to alter the
> definition of a View, depending on user input/selection. Essentially,
> the user is selecting a property of known coordinates (‘x’,’y’) and
> setting a ‘buffer’ distance . I then want to retrieve the records which
> represent the map features within the specified distance of the
> property. The WHERE clause of my view is:
>
> st_dwithin(mytable.geom, st_setsrid(st_point(x, y), 27700), buffer);
>
> I’m thinking this could be achieved either by making x, y and buffer
> parameters or, I simply ALTER the View statement with literal values.
> Whichever, I need to do this from a command line attached to a windows
> form event, e.g. button_click.
>
> I cannot work out how to do this. Can anyone point me in the right
> direction. I’ve looked at psql.exe, but can’t work out if this holds the
> answer.
>
> Thanks
>
> Oisin
>

Changing the view on the fly is a bad idea. Multiple users would step
all over themselves.

I see two options:

1) don't do the where inside the view. Have the view return the column
and have the client generate the where. so client would run:

select * from view where st_dwithin(geom, st_setsrid(st_point(x, y),
27700), buffer);

2) convert it to a stored procedure, which can take arguments, then have
the client run something like:

select * from mapFeat(42, 42, 27700)

-Andy

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jonathan Vanasco 2010-05-10 15:02:49 Re: question about unique indexes
Previous Message Ivan Voras 2010-05-10 12:18:06 Re: hstore problem with UNION?