Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 4133F2E0043 for ; Fri, 11 Apr 2008 14:48:23 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 07797-02 for ; Fri, 11 Apr 2008 14:48:12 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.179]) by developer.postgresql.org (Postfix) with ESMTP id 05EB82E002F for ; Fri, 11 Apr 2008 14:48:13 -0300 (ADT) Received: from webserv.wug.de ([194.25.154.138]) by mrelayeu.kundenserver.de (node=mrelayeu7) with ESMTP (Nemesis) id 0ML2xA-1JkNM7305D-0003Z0; Fri, 11 Apr 2008 19:48:11 +0200 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1JkNM6-0005U8-00 for pgsql-sql@postgresql.org; Fri, 11 Apr 2008 19:48:06 +0200 Date: Fri, 11 Apr 2008 19:48:06 +0200 From: "A. Kretschmer" To: pgsql-sql@postgresql.org Subject: Re: Get the last inserted id Message-ID: <20080411174806.GA21064@a-kretschmer.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: Debian/GNU Linux - weil ich es mir Wert bin! User-Agent: Mutt/1.5.9i X-Provags-ID: V01U2FsdGVkX18uesYtUq9Kl4HhKStFSyoMpkWKGrlpRohJWr3 qk5UTiyufBY73HdsPBohCXlnCoGJFzimtSUKIP2QlVcPH+K3le C5JUL9qnPjodmc9uXI37zS0qOSepS2n X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/79 X-Sequence-Number: 30618 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