From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Kevin Nikiforuk <Kevin(dot)Nikiforuk(at)Acrodex(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Error when trying to use a FOR loop |
Date: | 2006-07-21 16:01:44 |
Message-ID: | 20060721085524.R28101@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Hilary Forbes | 2006-07-21 16:19:45 | Re: System catalog table privileges |
Previous Message | Tom Lane | 2006-07-21 15:40:11 | Re: Error when trying to use a FOR loop |