Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-novicepgsql-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

pgsql-novice by date

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

pgsql-general by date

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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group