Re: FOR-IN-EXECUTE, why fail?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: mmarencibia(at)yahoo(dot)es (Marcos Medina)
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: FOR-IN-EXECUTE, why fail?
Date: 2004-07-19 04:23:21
Message-ID: 8713.1090211001@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice pgsql-sql

mmarencibia(at)yahoo(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-07-19 04:33:40 Re: Horology & stats tests fail in 7.4.3/RH 9
Previous Message Matthew T. O'Connor 2004-07-18 23:46:26 Re: Fwd: Indexes and Tables: Growth and Treatment

Browse pgsql-novice by date

  From Date Subject
Next Message Bob Jarman 2004-07-19 21:59:13 PyPgSQL help
Previous Message Tom Lane 2004-07-19 04:05:48 Re: SQL - Indexing for performance on uniquness check...

Browse pgsql-sql by date

  From Date Subject
Next Message SZUCS Gabor 2004-07-19 08:47:40 Re: How do I convice postgres to use an index?
Previous Message Dario V. Fassi 2004-07-18 19:47:20 Re: [ADMIN] Migrate postgres databases from SQL_ASCII to UNICODE