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

From: Bret Green <bret(dot)green(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: how to insert multiple rows and get the ids back in a temp table (pgplsql)?
Date: 2010-09-19 01:43:49
Message-ID: 628416.19745.qm@web120415.mail.ne1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 one row it will be like this
insert into mytable(mycolumn)values(123)returning id into some_variable;

now for multiple rows (using insert select) it will be like

insert into mytable(mycolumn)
select other_column from other_table
returning id into ???

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thom Brown 2010-09-19 11:49:15 Database not starting up for hot standby
Previous Message Tom Lane 2010-09-18 15:50:23 Re: unintuitive subquery record wrapping