Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 60C889FB1C0 for ; Tue, 3 Apr 2007 04:12:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 65798-07 for ; Tue, 3 Apr 2007 04:12:39 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from smtpout30.attiva.biz (smtpout30.attiva.biz [85.37.16.8]) by postgresql.org (Postfix) with ESMTP id 6AA179FA274 for ; Tue, 3 Apr 2007 04:12:41 -0300 (ADT) Received: from fbcmfe02b11.fbc.local ([192.168.30.92]) by smtpout30.attiva.biz with Microsoft SMTPSVC(6.0.3790.1830); Tue, 3 Apr 2007 09:12:39 +0200 Received: from dream ([88.34.161.130]) by fbcmfe02b11.fbc.local with Microsoft SMTPSVC(6.0.3790.1830); Tue, 3 Apr 2007 09:12:37 +0200 Message-ID: <002701c775bf$847c9930$1102a8c0@dream> Reply-To: "Shavonne Marietta Wijesinghe" From: "Shavonne Marietta Wijesinghe" To: "Andrew Sullivan" , References: <00c301c77536$938a32e0$1102a8c0@dream> <20070402151726.GA30052@phlogiston.dyndns.org> Subject: Re: Update problem. Date: Tue, 3 Apr 2007 09:13:00 +0200 Organization: Studio FORM MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3028 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 X-OriginalArrivalTime: 03 Apr 2007 07:12:38.0659 (UTC) FILETIME=[76420530:01C775BF] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/17 X-Sequence-Number: 28017 Thanks. But to do the UPDATE i have to write each column name (for recrd 4) and with its column name (for record 2) which is quite alot to write :P UPDATE MOD48_00_2007 SET te_cognome= te_cognome, te_paternita= te_paternita WHERE N_GEN= 9 so it will be like that? But i have to set each column name = to the column name. And i have to do it for echt field? isn't there any other way.. "I hate writting :P" And Andrew can explain a bit the setval() Thanks Shavonne Wijesinghe From: "Andrew Sullivan" To: Sent: Monday, April 02, 2007 5:17 PM Subject: Re: [SQL] Update problem. > 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 > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend