Re: Is this possible or am I on drugs :) - Mailing list pgsql-general

From Tom Lane
Subject Re: Is this possible or am I on drugs :)
Date
Msg-id 13697.975390506@sss.pgh.pa.us
Whole thread Raw
In response to Re: Is this possible or am I on drugs :)  (shawn everett <everett@pgweb.com>)
Responses Re: Is this possible or am I on drugs :)  (shawn everett <everett@pgweb.com>)
List pgsql-general
shawn everett <everett@pgweb.com> writes:
> What I'd like to figure out is the best way to handle the say ~30
> calculations I'll need to do to generate the report.  I could query the
> database and then do the calcuations in code via php, I could do them
> using one giant select statement, or I could possibly dump them all into a
> view provided I could find a way to pass a parameter to the view.

What do you consider "passing a parameter to the view" to be?

A view is a table --- one computed on-demand, rather than stored, but
still a table.  You can use a SELECT ... WHERE to select a subset of
the rows in the table, and (with any luck ;-)) only those rows will
get computed.

If you can express your parameterization in terms of selecting some
rows and not others from a (possibly very large) virtual table, you're
all set.

There will probably be support in 7.2 or so for functions returning
recordsets as SELECT sources.  A construct like

    SELECT * FROM myfunc(42, 'foo');

would be a truly parameterized view, I think.  But we can't do it today.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Cannot createdb a database I just "destroydb"'d
Next
From: shawn everett
Date:
Subject: Re: Is this possible or am I on drugs :)