How do you batch insert and still obtain identity?

From: Robert Nicholson <robert(dot)nicholson(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: How do you batch insert and still obtain identity?
Date: 2009-10-03 21:28:46
Message-ID: 847CAC0D-29A7-472F-9DF1-D4B657BAAD75@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

So, when you make use of Serial, or Autoincrement fields how is it
possible to insert in a batch update and then learn the identity of
the rows you should inserted?

Is it my understanding that when you want to do bulk inserts thru
batch update that you are required to provide the primary keys having
called a sequence or obtained them
before hand since there's no way int he result of an update to obtain
the identity of the rows you've just inserted. It is puzzling to me
that JDBC doesn't allow you to do this
given that it can tell you which statement (by index) succeeded or
failed.

Browse pgsql-jdbc by date

  From Date Subject
Next Message Ying-Wen Chen 2009-10-06 12:29:29 callable statement cannot work when call stored procedure @postgres84
Previous Message Tom Lane 2009-10-02 19:26:29 Re: Compression