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

Re: Why this does not work ??

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To:
Cc: Roberto Rezende de Assis <rezende_assis(at)yahoo(dot)com(dot)br>,Postgesql list <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Why this does not work ??
Date: 2004-07-04 03:07:11
Message-ID: 26744.1088910431@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
I wrote:
> The loop variable of a for/select loop has to be a record or rowtype
> variable.  So you should do something like

>     declare
>         r record;
>     begin
>         for r in select * from original order by num asc loop
>             insert into copia(num) values(r.num);

>> WARNING:  plpgsql: ERROR during compile of copiar near line 4
>> ERROR:  missing .. at end of SQL expression

> I agree that this error message is not very helpful :-(

FYI, I have just committed some fixes that will hopefully provide more
helpful error messages for erroneous FOR-loops.  Your example will
draw

ERROR:  loop variable of loop over rows must be a record or row variable

in PG 7.5.

			regards, tom lane

In response to

pgsql-novice by date

Next:From: Markus BertheauDate: 2004-07-04 10:10:51
Subject: Re: Why this does not work ??
Previous:From: Tom LaneDate: 2004-07-03 21:56:45
Subject: Re: Why this does not work ??

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