From: | Bret Green <bret(dot)green(at)yahoo(dot)com> |
---|---|
To: | Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: how to insert multiple rows and get the ids back in a temp table (pgplsql)? |
Date: | 2010-09-20 00:33:52 |
Message-ID: | 735430.31920.qm@web120406.mail.ne1.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
No I do need it inside pgplsql. I need pgplsql for other stuff.
________________________________
From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: Bret Green <bret(dot)green(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Sent: Sun, September 19, 2010 9:25:46 AM
Subject: Re: [GENERAL] how to insert multiple rows and get the ids back in a
temp table (pgplsql)?
On 19 Sep 2010, at 3:43, 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 one row it will be like this
>
> insert into mytable(mycolumn)values(123)returning id into some_variable;
You can do that for multiple rows just fine, you don't even need plpgsql for
that:
development=> \d test
Table "public.test"
Column | Type | Modifiers
--------+---------+-----------
i | integer |
development=> INSERT INTO test (i) select x from generate_series(4, 10) t(x) ret
urning i;
i
----
4
5
6
7
8
9
10
(7 rows)
INSERT 0 7
Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.
!DSPAM:1170,4c96399610251136218112!
From | Date | Subject | |
---|---|---|---|
Next Message | Bret Green | 2010-09-20 00:34:54 | Re: how to insert multiple rows and get the ids back in a temp table (pgplsql)? |
Previous Message | Thom Brown | 2010-09-19 17:47:20 | Re: Database not starting up for hot standby |