Is there something like an dynamic view ? - Mailing list pgsql-general

From Andreas
Subject Is there something like an dynamic view ?
Date
Msg-id 4012B013.5020904@gmx.net
Whole thread Raw
List pgsql-general
Hi,

I'd like to fetch a selection of records out of a big n:m-relation.
It's something like:
customers (c_id, c_name, c_address, ....);
projects (p_id, p_name, c_start,  ....);
cp_relation (c_id, p_id, status_id, ....);

I use Access2000 as client.
The user selects an project_id by a combobox in the customer form. Then
the form should limit it's scope to only those customers that relate to
this project. The form's recordsource should be a SELECT that fetches
just the relevant customer-ids and collects the individual customer's
data when his id is current record.

I'd rather not let Access do the SELECT locally because then the whole
cp_relation had to be transferred.
A postgres-view would be as far as I know static. That is I'd need a
seperate view for every project. That's possible but seems a bit unelegant.
It would be:
view1 :   SELECT c_id FROM cp_relation WHERE p_id = 1;
view2 :   SELECT c_id FROM cp_relation WHERE p_id = 2;
view3 :   SELECT c_id FROM cp_relation WHERE p_id = 3;
...

That screams for a parameter.
Is this possible ?


Thanks for reading so far
Andreas

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Touch row ?
Next
From: "Lee Harr"
Date:
Subject: Re: pl/pgsql docs 37.4.3. Row Types -- how do I use this