Good day, there is such a code
CREATE OR REPLACE FUNCTION SubmitReview() RETURNS VOID AS $$ declare a INT; begin a := 1; while a <= (select max(id_) from test_f) loop insert into consumer (id_, name_, type_, abonentid_) values ((select max(id_)+1 from consumer), (select name_ from test_f where id_ = a), (select type_ from test_f where id_ = a), (select abonentid_ from test_f where id_ = a) ); a = a + 1; end loop; end $$ LANGUAGE plpgsql; those. The consumer table must be filled with fields from the TEST_F TABLE, for this there is a counter a. cycle compiles but nothing happens
insert into consumer (name_, type_, abonentid_) select name_,type_,abonentid_ from test_fonly need to have the id itself assigned by normal means, max (id) +1 it is very crooked. - Mikeinsert into consumer (id_,name_, type_, abonentid_) select maxId+row_number() over(order by id_),name_,type_,abonentid_ from test_f, (select max(id_) maxId from consumer) M- Mike