From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Kevin Nikiforuk <Kevin.Nikiforuk@Acrodex.com>
Cc: Erik Jones <erik@myemma.com>
Cc: Rodrigo De Leon <rdeleonp@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: CREATE TABLE AS inside of a function
Date: Mon, 24 Jul 2006 15:04:47 -0700 (PDT)
Message-ID: <20060724144553.T65749@megazone.bigpanda.com> (raw)
In-Reply-To: <6EA72AC41F81D242A38AAF505523A94D022DFC@kappa.acrodex.net>
References: <6EA72AC41F81D242A38AAF505523A94D022DFC@kappa.acrodex.net>
On Mon, 24 Jul 2006, Kevin Nikiforuk wrote:
> So, I've changed my code as Erik suggested:
>
> CREATE OR REPLACE FUNCTION rgio() RETURNS INTEGER as $$
> DECLARE
> lv RECORD;
>
> BEGIN
> FOR lv IN SELECT DISTINCT rg
> FROM ldevrg
> LOOP
>
> EXECUTE 'CREATE TABLE rgio_' || $lv || ' AS
> SELECT ldev
> FROM ldevrg
> WHERE rg=' || quote_literal($lv) || ';'
I think you want something like lv.rg (no special punctuation) rather than
$lv in the above.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone.bigpanda.com, Kevin.Nikiforuk@Acrodex.com, erik@myemma.com, rdeleonp@gmail.com
Subject: Re: CREATE TABLE AS inside of a function
In-Reply-To: <20060724144553.T65749@megazone.bigpanda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox