From: spastor@motionsponsor.com
To: pgsql-jdbc@postgresql.org
Subject: Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
Date: Wed, 20 Feb 2008 12:25:47 +0100
Message-ID: <39512.1203506747@motionsponsor.com> (raw)
Thanks Heikki !
That makes things clear to me now, i ll go on with the RETURNING method as i have no restrictions in term of portability at all (lucky me :))
Thanks again
Cheers
Seb.
Le mer , "Heikki Linnakangas" a écrit:
>spa
>stor@motionsponsor.com wrote:
>> Only one exception is regarding the best method to
>retrieve the last inserted id (serial). There are many posts on this topic
>but i couldn t find a definitive response.
>> I am using postgresql version 8.2.6 and jdbc 8.2_p505,
>i ve been experiencing INSERT statement with RETURNING myID, using an
>executeQuery it works great, i retrieve the proper value everytime at least
> from the few tests i have been doin locally.
>> Is it THAT easy or could this method break somehow in a
>live environement ?
>
>
>It is that easy, and that is a good way to do it.
>
>
>
>Alternatively, if you need to support older PostgreSQL version for
>
>example, you could use a "SELECT currval('sequence')" query after the
>
>INSERT.
>
>
>
>Much of the of discussion you saw were probably about implementing the
>
>JDBC getGeneratedKeys() function that some applications need for
>
>portability reasons, or because of middleware that doesn't know how to
>
>do INSERT RETURNING. PostgreSQL driver doesn't support that at the
>
>moment, but as long as you don't need it, you'll be fine.
>
>
>
>--
>
>Heikki Linnakangas
>
>EnterpriseDB http://www.enterprisedb.com
>
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: spastor@motionsponsor.com
Subject: Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
In-Reply-To: <39512.1203506747@motionsponsor.com>
References: <39512.1203506747@motionsponsor.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox