X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id E97AECC3C6 for ; Tue, 15 Jul 2003 15:49:57 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 30270-05 for ; Tue, 15 Jul 2003 15:50:26 +0000 (GMT) Received: from mail1.dr.myx.net (mail1.dr.myx.net [217.10.193.161]) by svr1.postgresql.org (Postfix) with ESMTP id 959F9CB9AA for ; Tue, 15 Jul 2003 12:49:56 -0300 (ADT) Received: from workstation24 (unknown [81.12.137.146]) by mail1.dr.myx.net (mydomain.myx.net) with ESMTP id BF14F300649; Tue, 15 Jul 2003 18:50:12 +0300 (EEST) Message-ID: <016101c34ae8$b4277a20$0600a8c0@fix.ro> From: "Viorel Dragomir" To: "Tom Lane" Cc: References: <20030715140921.7c5a6a6c.erik@thiele-hydraulik.de> <001501c34aca$e70ca280$0600a8c0@fix.ro> <20030715143925.54716ed4.erik@thiele-hydraulik.de> <22671.1058282096@sss.pgh.pa.us> <012b01c34ae6$40ab0870$0600a8c0@fix.ro> <22931.1058283723@sss.pgh.pa.us> Subject: Re: summing tables Date: Tue, 15 Jul 2003 18:49:40 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/187 X-Sequence-Number: 14301 ----- Original Message ----- From: "Tom Lane" To: "Viorel Dragomir" Cc: Sent: Tuesday, July 15, 2003 6:42 PM Subject: Re: [SQL] summing tables > "Viorel Dragomir" writes: > > Indeed it was a mistake not to put the table_name. in where clause. > > But this doesn't resolve the problem. > > > Do you know in which order the update will modify the rows? > > No, and *it does not matter*. You are forgetting that this all runs > under MVCC rules. The sub-SELECTs will see the pre-existing versions > of the rows, whether or not the UPDATE has yet produced new versions. Yes that was correct. I forgot that the subselect sees only the old rows. And the ORDER option will not make any difference, only making fool out of myself. :) I don't know if the problem is solved with my posted function. Anyway this is the mail that started all [i get a lot of emails and i'm not really searching for a solution on this matter]: " hi, i have a table consisting of 4 integers. seq is for making the table ordered. (ORDER BY SEQ ASC) a,b,c maybe null seq | a | b | c -----+----+----+--- 0 | 1 | 2 | 3 1 | 1 | 2 | 2 | 5 | 7 | 3 | -2 | -4 | i am needing a sql statement to do c=a+b+"the c of the row with seq one less than myself" this statement has to run over the whole table, in seq order. how can this be acomplished??? cu&thanks erik -- Erik Thiele "