Subject | Re: [firebird-support] Parametrized views? |
---|---|
Author | Martijn Tonies |
Post date | 2010-03-09T09:19:23Z |
Hello Pepak,
What's wrong with a normal VIEW and adding a WHERE
clause when you do a SELECT?
Martijn Tonies
Upscene Productions
http://www.upscene.com
Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!
Database questions? Check the forum:
http://www.databasedevelopmentforum.com
What's wrong with a normal VIEW and adding a WHERE
clause when you do a SELECT?
>I wonder: Is there any support, or any plan for support, forWith regards,
> parametrized views in Firebird? I find myself quite routinely in
> situations where I could use them. E.g. I have tables products (id,
> name, ...) and sales (product_id, date_and_time, amount, ...) and need
> to display product sales in a given period: SELECT products.*,
> SUM(amount) FROM products LEFT JOIN sales ON
> sales.product_id=products.id WHERE sales.date_and_time BETWEEN
> :date_from AND :date_to GROUP BY products.id, .... In this simple case a
> manually-built query works well enough, but most of my cases are far
> more complex. It would be very useful for me if I could create a view
> that would look something like this:
>
> CREATE VIEW sale_sums (PARAM date_from TIMESTAMP, PARAM date_to
> TIMESTAMP, product_id, amount) AS SELECT product_id, SUM(amount) FROM
> sales WHERE date_and_time BETWEEN :date_from AND :date_to GROUP BY
> product_id;
>
> With Firebird 2.1, I can get almost the same functionality with SELECT
> ... FROM (SELECT ...), but parametrized views would be a lot easier to
> read as well as faster to execute.
Martijn Tonies
Upscene Productions
http://www.upscene.com
Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!
Database questions? Check the forum:
http://www.databasedevelopmentforum.com