Re: Parameterized views proposition

Поиск
Список
Период
Сортировка
От Tambet Matiisen
Тема Re: Parameterized views proposition
Дата
Msg-id A66A11DBF5525341AEF6B8DE39CDE770088054@black.aprote.com
обсуждение исходный текст
Ответ на Parameterized views proposition  ("Tambet Matiisen" <t.matiisen@aprote.ee>)
Ответы Re: Parameterized views proposition  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Christoph Haller
Дата:
Сообщение: Re: How to cast VARCHAR to BYTEA and vice-versa?
Следующее
От: U K Laxmi
Дата:
Сообщение: comparing 2 tables