| From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
|---|---|
| To: | Kevin Nikiforuk <Kevin(dot)Nikiforuk(at)Acrodex(dot)com> |
| Cc: | Erik Jones <erik(at)myemma(dot)com>, Rodrigo De Leon <rdeleonp(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: CREATE TABLE AS inside of a function |
| Date: | 2006-07-24 22:04:47 |
| Message-ID: | 20060724144553.T65749@megazone.bigpanda.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Otniel Michael | 2006-07-25 07:57:26 | About Div |
| Previous Message | Bruno Wolff III | 2006-07-24 21:22:36 | Re: Referential integrity (foreign keys) across multiple tables |