X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 544D49DC806 for ; Fri, 3 Mar 2006 06:50:39 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24762-10 for ; Fri, 3 Mar 2006 06:50:41 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from 137086.vserver.de (vs137086.vserver.de [62.75.137.86]) by postgresql.org (Postfix) with ESMTP id 0A37F9DC84E for ; Fri, 3 Mar 2006 06:50:36 -0400 (AST) Received: from a-kretschmer.de (p54B38130.dip0.t-ipconnect.de [84.179.129.48]) (authenticated bits=0) by 137086.vserver.de (8.12.8/8.12.8) with ESMTP id k23Aob8k025058 for ; Fri, 3 Mar 2006 11:50:38 +0100 Received: from kretschmer by a-kretschmer.de with local (Exim 4.60) (envelope-from ) id 1FF7sm-0006kF-VL for pgsql-sql@postgresql.org; Fri, 03 Mar 2006 11:51:36 +0100 Date: Fri, 3 Mar 2006 11:51:36 +0100 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: newbie question Message-ID: <20060303105136.GA25541@KanotixBox> References: <1141378989.5311.13.camel@geologia5.agora.ing.unipg.it> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1141378989.5311.13.camel@geologia5.agora.ing.unipg.it> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: mutt-ng 1.5.9i (Linux) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.124 required=5 tests=[AWL=0.124] X-Spam-Score: 0.124 X-Spam-Level: X-Archive-Number: 200603/68 X-Sequence-Number: 24414 ivan marchesini schrieb: > Dear users.. > I have fastly created a table in a postgresql database.. > some columns where edited by hand (columns A, B, C), and some others > (columns D, E, F) have been calculated as a result of mathematical > equation (where the factors are the A, B, C columns).... You should create a table with (a,b,c) and a view. Below a example. test=# create table foo (a int, b int, c int); CREATE TABLE test=# create view foo_view as (select a,b,c,a*b as ab, a*c as ac, b*c as bc from foo); CREATE VIEW > now I simply need to change some values in the A, B, C columns and I > would like to obtain the correct values in the D, E, F column... > I know that this is a tipical problem of a spreadsheet but how can I > solve it with a DBMS?? test=# insert into foo values (2,3,4); INSERT 0 1 test=# select * from foo_view ; a | b | c | ab | ac | bc ---+---+---+----+----+---- 2 | 3 | 4 | 6 | 8 | 12 (1 row) test=# update foo set a=3; UPDATE 1 test=# select * from foo_view ; a | b | c | ab | ac | bc ---+---+---+----+----+---- 3 | 3 | 4 | 9 | 12 | 12 (1 row) HTH, Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknow) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°