... > > 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 ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend