X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9AA27529F5 for ; Thu, 7 Jul 2005 15:21:17 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81990-10 for ; Thu, 7 Jul 2005 18:21:14 +0000 (GMT) Received: from europa.telenet-ops.be (europa.telenet-ops.be [195.130.132.60]) by svr1.postgresql.org (Postfix) with ESMTP id C79735299D for ; Thu, 7 Jul 2005 15:21:10 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by europa.telenet-ops.be (Postfix) with SMTP id 116EF1981EB; Thu, 7 Jul 2005 20:21:11 +0200 (MEST) Received: from [192.168.0.236] (dD5E04CB3.access.telenet.be [213.224.76.179]) by europa.telenet-ops.be (Postfix) with ESMTP id 9912C198206; Thu, 7 Jul 2005 20:21:10 +0200 (MEST) Message-ID: <42CD7298.7040504@techevolution.be> Date: Thu, 07 Jul 2005 20:21:12 +0200 From: mail TechEvolution User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: nl-NL, nl, en MIME-Version: 1.0 To: Alvaro Herrera , pgsql-sql@postgresql.org Subject: Re: getting back autonumber just inserted References: <42CD6B58.6060508@techevolution.be> <20050707180329.GA11332@alvh.no-ip.org> In-Reply-To: <20050707180329.GA11332@alvh.no-ip.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200507/41 X-Sequence-Number: 22019 hi Alvaro Herrera >> You use the currval() function, using the name of the involved sequence >> as parameter. There is a pg_get_serial_sequence() function, to which >> you give the table name and column name thx for the information and is there a function i can use to get the last added autonumber without knowing wich table or row? (exactly as select @@ IDENTITY does?) i have read in the messages that there must be such a function for version 8.0, but i could not find it in the documentation, any idea on it? greetZ wes Alvaro Herrera schreef: >On Thu, Jul 07, 2005 at 07:50:16PM +0200, mail TechEvolution wrote: > > >>hello >> >>i ame a newbie to PostGreSQL, I ame using PostGreSQL 8.0 >>(windowsinstaller) on a xp prof platform >> >>i would like to get back the autonumber from the last record inserted, >>for other SQL db (m$ sql db ...) i could use: >>SELECT @@ IDENTITY >> >>can someone help me by informing me what the SQL syntax is to be used >>with PostGreSQL db and get the same result, the last autonumber inserted? >> >> > >You use the currval() function, using the name of the involved sequence >as parameter. There is a pg_get_serial_sequence() function, to which >you give the table name and column name, and it will give you the >sequence name. > > >