Re: conditional joins and views - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: conditional joins and views
Date
Msg-id 200704242208.42839.peter_e@gmx.net
Whole thread Raw
In response to conditional joins and views  (Jonathan Vanasco <postgres@2xlp.com>)
List pgsql-general
Am Dienstag, 24. April 2007 21:43 schrieb Jonathan Vanasco:
> Is it possible at all to use conditional joins in views?
>
> ie:
>     select a.* , b.* from a inner join b ON ( (a.id = b.id) AND
> (a.otherfield <> ?) )
>
> I have a few 15-20 table joins that i'd like to push into views.
> i've never wanted to push something with a conditional join into a
> view before, so am at a loss on this being a possibility.

I think what you are looking for is a parametrized view, but that doesn't
exist.

One obvious solution is to put this into a function, but that might not have
the best performance, depending on what sort of contexts you want to use the
view in.

Another option would be using prepared statements.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

pgsql-general by date:

Previous
From: William Garrison
Date:
Subject: postgres on Windows: PAE and max memory
Next
From: Ben
Date:
Subject: reasonable limit to number of schemas in a database?