Subject Re: [firebird-support] Is it possible to have a view with parameters?
Author PenWin
> You create the view over an entire set of data. Then, when you want
> to use the view, you use it like a table, including SELECTing from
> it. If the data set is not naturally updatable, you can make it so,
> using triggers.
>

That's an answer to a different question, though. Parametrized VIEWs do
have their uses and can be very useful in specific cases. Using WHERE
clauses on completed views may achieve the same result, but often at a
serious performance cost. Or it may not be possible to use the WHERE
clause on VIEW at all, you need it in the VIEW definition.

Example (non-working, but giving the general idea):

CREATE VIEW price_diff(product, price, difference)
AS SELECT product, price, price-(SELECT price FROM products WHERE
product=:my_product) FROM products;

SELECT * FROM price_diff(123);
SELECT * FROM price_diff(456);

Pepak