X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id EC89CD1D26A for ; Tue, 9 Mar 2004 15:15:07 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 51715-08 for ; Tue, 9 Mar 2004 11:15:05 -0400 (AST) Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net [194.217.242.91]) by svr1.postgresql.org (Postfix) with ESMTP id B717BD1BA44 for ; Tue, 9 Mar 2004 11:15:00 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) id 1B0iwd-000DxG-0X; Tue, 09 Mar 2004 15:15:00 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 140DC17884; Tue, 9 Mar 2004 15:14:58 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id E796017017; Tue, 9 Mar 2004 15:14:56 +0000 (GMT) From: Richard Huxton To: ow , pgsql-sql@postgresql.org Subject: Re: currval() without specifying the sequence name Date: Tue, 9 Mar 2004 15:14:56 +0000 User-Agent: KMail/1.5 References: <20040309135021.57085.qmail@web60808.mail.yahoo.com> In-Reply-To: <20040309135021.57085.qmail@web60808.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200403091514.56649.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/85 X-Sequence-Number: 17184 On Tuesday 09 March 2004 13:50, ow wrote: > Hi, > > Is there a way to retrieve the current value (i.e. the last used value) of > the last used sequence without specifying the sequence name? Something like > the following: > > create table ( id serial, value varchar(10)); > insert into someOthertest (value) values ('100'); > insert into test (value) values ('10'); > insert into test (value) values ('20'); > > select currval() should returns 2 (the last value of the test table > sequence) Not really - what if two sequences had been used? -- Richard Huxton Archonet Ltd