Re: Why this does not work ??

From: Jason Davis <jasdavis(at)bigpond(dot)com>
To: Roberto Rezende de Assis <rezende_assis(at)yahoo(dot)com(dot)br>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Why this does not work ??
Date: 2004-07-02 05:39:59
Message-ID: 5.1.0.14.0.20040702153706.0270b8f0@mail.bigpond.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


>Hello all, why this does not work ?
>
>-----------------------------------------
>create table original(num int);
>-----------------------------------------
>create table copia(num int);
>-----------------------------------------
>insert into original(num) values (1);
>insert into original(num) values (2);
>insert into original(num) values (3);
>-----------------------------------------
>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);
> end loop;
> return 1;
> end;
> ' language plpgsql;
>-----------------------------------------
>-----------------------------------------
>-----------------------------------------

Try this...

create function copiar()
returns int as '
declare
ponteiro record;
begin
for ponteiro in select * from original order by num asc loop
insert into copia(num) values(ponteiro.num);
end loop;
return 1;
end;
' language plpgsql;

cheers
Jason

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Oliver Elphick 2004-07-02 08:47:56 Re: .pgpass
Previous Message mike g 2004-07-02 04:19:50 Re: Formatting text strings in fields