Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 6B8369FB352 for ; Mon, 2 Apr 2007 12:17:45 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 06694-10 for ; Mon, 2 Apr 2007 12:17:33 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 590819FB2E4 for ; Mon, 2 Apr 2007 12:17:33 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1HYOHk-0006MQ-FD for pgsql-sql@postgresql.org; Mon, 02 Apr 2007 11:17:32 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id D01E93FAF; Mon, 2 Apr 2007 11:17:26 -0400 (EDT) Date: Mon, 2 Apr 2007 11:17:26 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Update problem. Message-ID: <20070402151726.GA30052@phlogiston.dyndns.org> References: <00c301c77536$938a32e0$1102a8c0@dream> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00c301c77536$938a32e0$1102a8c0@dream> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/9 X-Sequence-Number: 28009 On Mon, Apr 02, 2007 at 04:52:46PM +0200, Shavonne Marietta Wijesinghe wrote: > At a surtain point i need to replace a record with another > > For example i have inserted 4 records. (1, 2 , 3 , 4) I need to > replace all the values from the record 4 to the record 2 but > keeping the n_gen serial key. And then delete the record 4. So that > the next record i insert will take the n_gen 4 If I understand you correclty, you can do an UPDATE to record 4 to record 2, then do a setval() on the sequence. The setval() is tricky, though, because you have the problem that other connections could be using it. I'd lock the table in question while you did all this. A -- Andrew Sullivan | ajs@crankycanuck.ca Unfortunately reformatting the Internet is a little more painful than reformatting your hard drive when it gets out of whack. --Scott Morris