Re: Error when trying to use a FOR loop - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: Error when trying to use a FOR loop
Date
Msg-id 20060721085524.R28101@megazone.bigpanda.com
Whole thread Raw
In response to Re: Error when trying to use a FOR loop  ("Kevin Nikiforuk" <Kevin.Nikiforuk@Acrodex.com>)
List 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
thatI 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.


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: System catalog table privileges
Next
From: Hilary Forbes
Date:
Subject: Re: System catalog table privileges