From: | "Tambet Matiisen" <t(dot)matiisen(at)aprote(dot)ee> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Parameterized views proposition |
Date: | 2005-03-15 09:33:33 |
Message-ID: | A66A11DBF5525341AEF6B8DE39CDE770088054@black.aprote.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
...
>
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | U K Laxmi | 2005-03-15 09:36:16 | comparing 2 tables |
Previous Message | Christoph Haller | 2005-03-15 09:09:04 | Re: How to cast VARCHAR to BYTEA and vice-versa? |