Re: FOR-IN-EXECUTE, why fail? - Mailing list pgsql-novice

From Tom Lane
Subject Re: FOR-IN-EXECUTE, why fail?
Date
Msg-id 8713.1090211001@sss.pgh.pa.us
Whole thread Raw
In response to FOR-IN-EXECUTE, why fail?  (mmarencibia@yahoo.es (Marcos Medina))
List pgsql-novice
mmarencibia@yahoo.es (Marcos Medina) writes:
> I wrote the following:
> CREATE OR REPLACE FUNCTION escritorio.seq_valor_actual( text)
>  DECLARE
> ...
>      actual integer;
>  BEGIN
> ...
>  FOR actual IN EXECUTE v_query LOOP

The loop variable has to be a record or row variable, not an integer.

FWIW, 7.5 will give a better error message for this common mistake.
In CVS tip I get

ERROR:  loop variable of loop over rows must be a record or row variable at or near "LOOP" at character 416
LINE 14:  FOR actual IN EXECUTE v_query LOOP
                                        ^

            regards, tom lane

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: SQL - Indexing for performance on uniquness check...
Next
From: Gaetano Mendola
Date:
Subject: Re: FOR-IN-EXECUTE, why fail?