From: Andrew Sullivan <ajs@crankycanuck.ca>
To: pgsql-sql@postgresql.org
Subject: Re: Get the last inserted id
Date: Fri, 11 Apr 2008 13:57:44 -0400
Message-ID: <20080411175744.GA29043@crankycanuck.ca> (raw)
In-Reply-To: <f16f7ea00804111023xc2072ddk796b1e0336c14aac@mail.gmail.com>
References: <f16f7ea00804111023xc2072ddk796b1e0336c14aac@mail.gmail.com>
On Fri, Apr 11, 2008 at 07:23:04PM +0200, Nacef LABIDI wrote:
> Hi all,
>
> I was wondering if postgres can return the last ID inserted for a table
> which the primary key is autoincremented. I need to retrieve this ID in my
> code to continue processing on that inserted row.
Use select currval() on the sequence name.
A
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ajs@crankycanuck.ca
Subject: Re: Get the last inserted id
In-Reply-To: <20080411175744.GA29043@crankycanuck.ca>
* 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