X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C77A8D1B4EE for ; Sat, 20 Sep 2003 10:05:47 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 11505-09 for ; Sat, 20 Sep 2003 07:05:39 -0300 (ADT) Received: from anchor-post-37.mail.demon.net (anchor-post-37.mail.demon.net [194.217.242.87]) by svr1.postgresql.org (Postfix) with ESMTP id A6AC6D1B4E2 for ; Sat, 20 Sep 2003 07:05:31 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) id 1A0ecP-0000vB-0b; Sat, 20 Sep 2003 11:05:33 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 26DDC16660; Sat, 20 Sep 2003 11:05:32 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 3DFEA15957; Sat, 20 Sep 2003 11:05:31 +0100 (BST) From: Richard Huxton To: "Muhyiddin A.M Hayat" , Subject: Re: auto_increment Date: Sat, 20 Sep 2003 11:05:30 +0100 User-Agent: KMail/1.5 References: <001d01c37f3e$983ed3a0$2363a8c0@ckeskin> <002201c37f54$29608e40$1f00a8c0@middinkcomp> In-Reply-To: <002201c37f54$29608e40$1f00a8c0@middinkcomp> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200309201105.30370.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/218 X-Sequence-Number: 15196 On Saturday 20 September 2003 09:43, Muhyiddin A.M Hayat wrote: > Ok, but if i do rollback, the auto_increment don't roolback. It's not supposed to. > How to use nextval(), currval() and setval() functions. Something like: INSERT INTO my_table(nextval('my_sequence_name'),'aaa',1); But you'll get the same problem. What are you trying to do with the auto-increment? If you want to guarantee that the numbers go up in sequence and have no gaps (e.g. 1,2,3,4,5 NOT 1,2,4,6) then you'll need to do some more work. Think about what you want to have happen when three clients insert rows at the same time and one rolls back. Once you've decided what you want, ask again if you need some help. -- Richard Huxton Archonet Ltd