Re: Get the last inserted id - Mailing list pgsql-sql

From A. Kretschmer
Subject Re: Get the last inserted id
Date
Msg-id 20080411174806.GA21064@a-kretschmer.de
Whole thread Raw
In response to Get the last inserted id  ("Nacef LABIDI" <nacef.l@gmail.com>)
List pgsql-sql
am  Fri, dem 11.04.2008, um 19:23:04 +0200 mailte Nacef LABIDI folgendes:
> 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.

Either with RETURNING:
http://www.postgresql.org/docs/current/static/sql-insert.html

or with currval():
http://www.postgresql.org/docs/current/static/functions-sequence.html


HTH, Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net


pgsql-sql by date:

Previous
From: "Nacef LABIDI"
Date:
Subject: Re: Get the last inserted id
Next
From: Andrew Sullivan
Date:
Subject: Re: Get the last inserted id