Re: generating dynamic queries using pl/pgsql - Mailing list pgsql-novice

From Sean Davis
Subject Re: generating dynamic queries using pl/pgsql
Date
Msg-id D3DEBB8D-6B0B-11D9-9D53-000D933565E8@mail.nih.gov
Whole thread Raw
In response to Re: generating dynamic queries using pl/pgsql  (sarlav kumar <sarlavk@yahoo.com>)
Responses Re: generating dynamic queries using pl/pgsql  (sarlav kumar <sarlavk@yahoo.com>)
List pgsql-novice
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


pgsql-novice by date:

Previous
From: sarlav kumar
Date:
Subject: Re: generating dynamic queries using pl/pgsql
Next
From: "Van Ingen, Lane"
Date:
Subject: What Do I Need to Get Started with PostreSQL for Win32 (version 8.0)