From: | Markus Bertheau <twanger(at)bluetwanger(dot)de> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
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 10:10:51 |
Message-ID: | 1088935851.2767.1.camel@teetnang |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
В Сбт, 03.07.2004, в 23:56, Tom Lane пишет:
> Roberto Rezende de Assis <rezende_assis(at)yahoo(dot)com(dot)br> writes:
> > Hello all, why this does not work ?
>
> > create function copiar()
> > returns int as '
> > declare
> > ponteiro int;
> > begin
> > for ponteiro in select * from original order by num asc loop
> > insert into copia(num) values(ponteiro);
>
> 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 :-(
FWIW, the documentation explicitly states this case and the unhelpful
error message it yields.
I haven't looked, but the docs would need fixing then, too.
Thanks.
--
Markus Bertheau <twanger(at)bluetwanger(dot)de>
From | Date | Subject | |
---|---|---|---|
Next Message | R.Welz | 2004-07-04 12:43:36 | plpgsql in RULE possible? |
Previous Message | Tom Lane | 2004-07-04 03:07:11 | Re: Why this does not work ?? |