| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Roberto Rezende de Assis <rezende_assis(at)yahoo(dot)com(dot)br> |
| Cc: | Postgesql list <pgsql-novice(at)postgresql(dot)org> |
| Subject: | Re: Why this does not work ?? |
| Date: | 2004-07-03 21:56:45 |
| Message-ID: | 23473.1088891805@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
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 :-(
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2004-07-04 03:07:11 | Re: Why this does not work ?? |
| Previous Message | Roberto Rezende de Assis | 2004-07-03 19:08:29 | Re: Why this does not work ?? (Now it has worked) |