From: Josh Berkus <josh@agliodbs.com>
To: Christoph Haller <ch@rodos.fzk.de>
To: pgsql-sql@postgresql.org
Subject: Re: PLpgSQL FOR IN EXECUTE question
Date: Thu, 07 Nov 2002 13:30:20 -0800
Message-ID: <web-1816701@davinci.ethosmedia.com> (raw)
In-Reply-To: <3DCA7A2E.6DD4CABE@rodos.fzk.de>
Chris,
> FOR this_record IN
> EXECUTE ''SELECT ''
> || quote_ident($1)
> || ''FROM ''
> || quote_ident($2)
> LOOP
> list := list || '', '' || this_record.$1 ;
> END LOOP;
>
> As expected, accessing a field via this_record.$1
> does not work.
> Can it be done otherwise?
Yes. Alias the columns:
FOR this_record IN
EXECUTE ''SELECT ''
|| quote_ident($1)
|| '' AS col1 FROM ''
|| quote_ident($2)
|| '' AS col2'' LOOP
list := list || '', '' || this_record.col1 ;
END LOOP;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: josh@agliodbs.com, ch@rodos.fzk.de
Subject: Re: PLpgSQL FOR IN EXECUTE question
In-Reply-To: <web-1816701@davinci.ethosmedia.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox