Re: how to insert multiple rows and get the ids back in a temp table (pgplsql)?

Поиск
Список
Период
Сортировка
От hubert depesz lubaczewski
Тема Re: how to insert multiple rows and get the ids back in a temp table (pgplsql)?
Дата
Msg-id 20100919141251.GB24997@depesz.com
обсуждение исходный текст
Ответ на how to insert multiple rows and get the ids back in a temp table (pgplsql)?  (Bret Green <bret.green@yahoo.com>)
Ответы Re: how to insert multiple rows and get the ids back in a temp table (pgplsql)?  (Bret Green <bret.green@yahoo.com>)
Список pgsql-general
On Sat, Sep 18, 2010 at 06:43:49PM -0700, Bret Green wrote:
> how can I do the following in plpgsql?
> insert multiple rows in a table
> get the ids (serial) into a temp table (not the client)

for temprec in insert into table (x) select y from z returning id loop
    insert into temp teable (q) values (temprec.id);
end loop;

Best regards,

depesz

--
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

В списке pgsql-general по дате отправления:

Предыдущее
От: Francisco Reyes
Дата:
Сообщение: Tables with autovacuum_enabled=false stillgetting vacuumed
Следующее
От: Alban Hertroys
Дата:
Сообщение: Re: how to insert multiple rows and get the ids back in a temp table (pgplsql)?