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.