Variable assignment from dynamic SQL in PL/PgSQL - Mailing list pgsql-hackers

From David Fetter
Subject Variable assignment from dynamic SQL in PL/PgSQL
Date
Msg-id 20040922032805.GB11648@fetter.org
Whole thread Raw
Responses Re: Variable assignment from dynamic SQL in PL/PgSQL  (Robert Treat <xzilla@users.sourceforge.net>)
List pgsql-hackers
Kind people,

I've figured out something that many others probably have, but I
thought I'd put it out there anyhow.

As PL/PgSQL doesn't allow assignment of singleton SELECTs and dynamic
queries to variables, as mentioned in the docs.

Here's a working hack that gets around this.

DECLARE foo_rec RECORD;
BEGIN   FOR foo_rec IN EXECUTE -- put together a singleton sql function here.   LOOP   END LOOP;   -- do stuff with
foo_rec.bar,foo_rec.baz, &c.
 
END;

Should this hack turn into a TODO item?  If so, what problems should
get addressed?  Features added?  Is PL/PgSQL in such shape as it needs
a big overhaul?

Anyway, thanks for taking the time to read this.

Cheers,
D
-- 
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100   mobile: +1 415 235 3778

Remember to vote!


pgsql-hackers by date:

Previous
From: Gavin Sherry
Date:
Subject: Re: testing concurrency (was Re: subtransaction assert
Next
From: Tom Lane
Date:
Subject: Re: testing concurrency (was Re: subtransaction assert failure)