From: Tambet Matiisen <t.matiisen@aprote.ee>
To: pgsql-sql@postgresql.org
Subject: Re: Parameterized views proposition
Date: Tue, 15 Mar 2005 11:33:33 +0200
Message-ID: <A66A11DBF5525341AEF6B8DE39CDE770088054@black.aprote.com> (raw)
...
>
> I wonder if it could be possible to improve CREATE VIEW
> syntax by adding parameters? Something like this:
>
> CREATE VIEW product_sales(date,date) AS
> select p.product_id, coalesce(sum(s.amount), 0)
> from product p
> left join sales s on p.product_id = s.product_id and s.date
> between $1 and $2 group by p.product_id
>
I noticed that braces after view name are already reserved for renaming
view columns. OK, then this syntax won't do. Isn't there some suggestion
in SQL standards? Quick search with Google revealed only that FoxPro has
parameterized views, but the syntax is quite different.
I've heard people talking about parameterized views since I started
database programming. So, PostgreSQL could be the first to really
implement them :). How tough it would be to implement
CREATE VIEW xxx PARAMETERS (yyy) AS zzz;
as
CREATE TYPE xxx;
CREATE FUNCTION xxx(yyy) RETURNING SETOF xxx LANGUAGE sql AS 'zzz';
Would you suggest it as first step in hacking PostgreSQL sources?
Tambet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: t.matiisen@aprote.ee
Subject: Re: Parameterized views proposition
In-Reply-To: <A66A11DBF5525341AEF6B8DE39CDE770088054@black.aprote.com>
References: <A66A11DBF5525341AEF6B8DE39CDE770088054@black.aprote.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox