Subject | Re: [firebird-support] Is it possible to have a view with parameters? |
---|---|
Author | PenWin |
Post date | 2011-03-31T05:24:45Z |
> You create the view over an entire set of data. Then, when you wantThat's an answer to a different question, though. Parametrized VIEWs do
> 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.
>
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