Re: CREATE TABLE AS inside of a function - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: CREATE TABLE AS inside of a function
Date
Msg-id 20060724144553.T65749@megazone.bigpanda.com
Whole thread Raw
In response to Re: CREATE TABLE AS inside of a function  ("Kevin Nikiforuk" <Kevin.Nikiforuk@Acrodex.com>)
List pgsql-sql
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.


pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Referential integrity (foreign keys) across multiple tables
Next
From: Otniel Michael
Date:
Subject: About Div