From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Kevin Nikiforuk <Kevin.Nikiforuk@Acrodex.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Error when trying to use a FOR loop
Date: Fri, 21 Jul 2006 09:01:44 -0700 (PDT)
Message-ID: <20060721085524.R28101@megazone.bigpanda.com> (raw)
In-Reply-To: <6EA72AC41F81D242A38AAF505523A94D022DF4@kappa.acrodex.net>
References: <6EA72AC41F81D242A38AAF505523A94D022DF4@kappa.acrodex.net>
On Fri, 21 Jul 2006, Kevin Nikiforuk wrote:
> Many thanks to Stephan, Richard and George. When I was reading the documentation about FOR loops, I didn't realize that I was in the plpgsql section!
>
> CREATE OR REPLACE FUNCTION rgio() RETURNS integer as $$
> BEGIN
> DECLARE lv RECORD;
You'd want to put declare first (it goes before begin).
> FOR lv IN SELECT DISTINCT rg FROM ldevrg LOOP
> SELECT ldev FROM ldevrg WHERE ldevrg='$lv';
I think you'd want something like ldevrg=lv.rg.
> END LOOP;
What's the final intent for this since AFAICS this is just going to do
busy work that throws away the results. If you wanted to see the results
of each of these selects you have to do a bit more work.
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: sszabo@megazone.bigpanda.com, Kevin.Nikiforuk@Acrodex.com
Subject: Re: Error when trying to use a FOR loop
In-Reply-To: <20060721085524.R28101@megazone.bigpanda.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