Skip site navigation (1) Skip section navigation (2)

Re: Get the last inserted id

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Get the last inserted id
Date: 2008-04-11 17:57:44
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
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.


In response to

pgsql-sql by date

Next:From: Emi LuDate: 2008-04-14 13:41:41
Subject: export CSV file through Java JDBC
Previous:From: A. KretschmerDate: 2008-04-11 17:48:06
Subject: Re: Get the last inserted id

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group