Variable assignment from dynamic SQL in PL/PgSQL

From: David Fetter <david(at)fetter(dot)org>
To: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Variable assignment from dynamic SQL in PL/PgSQL
Date: 2004-09-22 03:28:05
Message-ID: 20040922032805.GB11648@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778

Remember to vote!

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-09-22 04:01:54 Re: testing concurrency (was Re: subtransaction assert failure)
Previous Message Koju Iijima 2004-09-22 01:35:15 temporary view from TODO list