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 84509D1B979 for ; Tue, 9 Mar 2004 14:10:17 +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 37601-06 for ; Tue, 9 Mar 2004 10:10:15 -0400 (AST) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by svr1.postgresql.org (Postfix) with ESMTP id 8894ED1BA8F for ; Tue, 9 Mar 2004 10:10:09 -0400 (AST) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id i29EAhNu032677; Tue, 9 Mar 2004 16:10:43 +0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id i29EAhs8032673; Tue, 9 Mar 2004 16:10:43 +0200 Date: Tue, 9 Mar 2004 16:10:43 +0200 (EET) From: Achilleus Mantzios To: ow Cc: pgsql-sql@postgresql.org Subject: Re: currval() without specifying the sequence name In-Reply-To: <20040309135021.57085.qmail@web60808.mail.yahoo.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/81 X-Sequence-Number: 17180 O kyrios ow egrapse stis Mar 9, 2004 : > 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) You could use the same sequence in many tables. > > Thanks > > > > > __________________________________ > Do you Yahoo!? > Yahoo! Search - Find what you’re looking for faster > http://search.yahoo.com > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html > -- -Achilleus