Re: Variable assignment from dynamic SQL in PL/PgSQL

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: David Fetter <david(at)fetter(dot)org>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Variable assignment from dynamic SQL in PL/PgSQL
Date: 2004-09-22 17:19:09
Message-ID: 1095873549.14485.58.camel@camel
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 2004-09-21 at 23:28, David Fetter wrote:
> 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?
>

I believe this to be addressed already in 8.0, though I haven't had time
to confirm this... maybe you want to try it out on the beta release.

Robert Treat
--
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2004-09-23 00:11:02 BUG: possible busy loop when connection is closed while trying to establish SSL connection
Previous Message Josh Berkus 2004-09-22 16:03:06 Re: Companies, Version 8.0 release