Re: Schema handling within plpgsql

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: George McQuade <gm(at)winls(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Schema handling within plpgsql
Date: 2005-10-06 06:23:40
Message-ID: 20051006062340.GA89366@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Wed, Oct 05, 2005 at 05:45:45PM -0500, George McQuade wrote:
> What is the proper plpgsql syntax for looping through schemas?
> (postgresql 7.4.1)
>
> Ideally it would be nice to do something like:
>
> for schema in 1,2,3,4,5
> do
> create $schema.table ...
> insert into $schema.table select ....
> done

See "Executing Dynamic Commands" in the PL/pgSQL documentation:

http://www.postgresql.org/docs/7.4/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

--
Michael Fuhr

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Jaromír Kamler 2005-10-06 10:53:14 Re: stupid SQL question, how reach different rows of two almost same tables
Previous Message Michael Fuhr 2005-10-06 05:11:05 Re: contains function