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: 20080411175744.GA29043@crankycanuck.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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.

A

In response to

Browse pgsql-sql by date

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