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 593F9D1B534 for ; Wed, 10 Sep 2003 20:15:18 +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 70342-01 for ; Wed, 10 Sep 2003 17:14:49 -0300 (ADT) Received: from external.wtcm.be (mail.wtcm.be [212.224.138.150]) by svr1.postgresql.org (Postfix) with ESMTP id D2E26D1B52F for ; Wed, 10 Sep 2003 17:14:46 -0300 (ADT) Received: from server04.site04.wtcm.be (server04.site04.wtcm.be [192.168.64.1]) by external.wtcm.be (Postfix) with ESMTP id 1FDABD407D for ; Wed, 10 Sep 2003 22:03:25 +0200 (CEST) Received: from lt00027.wtcm.be by server04.site04.wtcm.be (8.8.8/1.1.22.3/18Aug99-1117AM) id WAA0000012031; Wed, 10 Sep 2003 22:14:46 +0200 (MET DST) Message-Id: <5.2.1.1.0.20030910220528.015ac238@server04.site04.wtcm.be> X-Sender: mey@server04.site04.wtcm.be (Unverified) X-Mailer: QUALCOMM Windows Eudora Version 5.2.1 Date: Wed, 10 Sep 2003 22:12:45 +0200 To: pgsql-sql@postgresql.org From: Patrick Meylemans Subject: change a field Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/125 X-Sequence-Number: 15103 Dear, I want to change a field of a record after the modification of another field of the same record or during an insert of a new record. Suppose the following table field | type ---------------------------------- id | serial sign | integer value | integer real_value | integer When inserting a new record, giving values to sign and value, the field real_value should be the product of the fields sign and value. When updating an existing record, the value of the field real_value should be recalculated. I tried with plpgsql functions and triggers but with no success. It works only when inserting new records and not when updating a field. What is the best way to solve this problem ? Kind regards Patrick Meylemans