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 0341E52A15 for ; Thu, 7 Jul 2005 17:14:39 -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 76354-09 for ; Thu, 7 Jul 2005 20:14:34 +0000 (GMT) Received: from web41013.mail.yahoo.com (web41013.mail.yahoo.com [66.218.93.12]) by svr1.postgresql.org (Postfix) with SMTP id E723252A22 for ; Thu, 7 Jul 2005 17:14:32 -0300 (ADT) Received: (qmail 94903 invoked by uid 60001); 7 Jul 2005 20:14:33 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=XOv/XRr9fIuKnUIp+Vcjn0RcImzXCqcFTr2SBFFXQIHcIHydomETsn9A2UQaYgkpjozv/ibj3QonjrGxVsiqvI8YbcpimENEiS3R3pp3F5MZqnQjO7RIby+6vjPpA0rYD6D547KeAIHI22oH5SN6YsxB34ZFU1+a60nmf54+/RY= ; Message-ID: <20050707201433.94901.qmail@web41013.mail.yahoo.com> Received: from [151.204.106.98] by web41013.mail.yahoo.com via HTTP; Thu, 07 Jul 2005 13:14:33 PDT Date: Thu, 7 Jul 2005 13:14:33 -0700 (PDT) From: Theodore Petrosky Subject: Re: getting back autonumber just inserted To: mail TechEvolution Cc: pgsql-sql@postgresql.org In-Reply-To: <42CD6B58.6060508@techevolution.be> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.257 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE X-Spam-Level: X-Archive-Number: 200507/43 X-Sequence-Number: 22021 you have to use currval inside a transaction... begin; insert something that increments the counter; select currval('sequence_name'); end; using currval inside a transaction guarantees that the value is correct for your insert statement and has not changed by another insert statement. Ted --- 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? > > greeTz > > wes > > ---------------------------(end of > broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > ____________________________________________________ Sell on Yahoo! Auctions – no fees. Bid on great items. http://auctions.yahoo.com/