On Jan 20, 2005, at 12:40 PM, sarlav kumar wrote:
> >Yes, it's possible.
>
> >http://www.postgresql.org/docs/7.4/interactive/plpgsql-
> statements.html#PLPGSQL->STATEMENTS-EXECUTING-DYN
> >The manual has some great information.
>
> I read through the manual. But I am still not clear how to actually
> generate the "queries" dynamically. In my case, some of the
> "select queries" that I want to dynamically generate have joins and
> some of the "select queries" are just from one table.
>
The point of section 37.6.4 (see the manual again) is that you can
build a query from a combination of text and variables. If you have
pieces of your query, you need to build up the full query using the ||
operator (concatenation). Then you can EXECUTE it.
As for "dumping" the table, look at:
http://www.postgresql.org/docs/7.4/interactive/sql-copy.html
You can use COPY to do this.
HTH,
Sean