![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
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); |
|
WARNING: plpgsql: ERROR during compile of copiar near line 4 ERROR: missing .. at end of SQL expression |
#4
| |||
| |||
|
|
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 :-( |
#5
| |||
| |||
|
|
Roberto Rezende de Assis <rezende_assis (AT) yahoo (DOT) com.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 :-( |
![]() |
| Thread Tools | |
| Display Modes | |
| |