Re: [SQL] plpgsql : adding record variable to table

2012-04-19 Thread Pavel Stehule
2012/4/19 thomas veymont : > that made it, thank you. > For other readers, here is what I finally did : > > CREATE TABLE mytable (...) > > CREATE FUNCTION (...) RETURNS SETOF  mytable AS $$ > DECLARE >  r mytable%rowtype > BEGIN > ... >  FOR r IN select * from mytable >     LOOP >       >

Re: [SQL] plpgsql : adding record variable to table

2012-04-19 Thread thomas veymont
that made it, thank you. For other readers, here is what I finally did : CREATE TABLE mytable (...) CREATE FUNCTION (...) RETURNS SETOF mytable AS $$ DECLARE r mytable%rowtype BEGIN ... FOR r IN select * from mytable LOOP RETURN next r; END LOOP; RETURN; END

Re: [SQL] plpgsql : adding record variable to table

2012-04-19 Thread Pavel Stehule
2012/4/19 thomas veymont : > hi Pavel, > > thanks for your answer, > > I don't understand exactly how "y" should be declared, and how it > should be returned by the function (as a table, > as a "set of record", or maybe as some kind of generic object, I don't > know exactly what's possible with pl

Re: [SQL] plpgsql : adding record variable to table

2012-04-19 Thread thomas veymont
hi Pavel, thanks for your answer, I don't understand exactly how "y" should be declared, and how it should be returned by the function (as a table, as a "set of record", or maybe as some kind of generic object, I don't know exactly what's possible with pl/psql.). cheers Tom 2012/4/18 Pavel Steh

Re: [SQL] plpgsql : adding record variable to table

2012-04-18 Thread Pavel Stehule
Hello please try: postgres=# create or replace function foo() returns void as $$ declare r x; begin for r in select * from x loop insert into y values(r.*); end loop; end; $$ language plpgsql; Regards Pavel 2012/4/18 thomas veymont : > (sorry my previous email was truncated) > > hi,