change a field

From: Patrick Meylemans <Patrick(dot)Meylemans(at)wtcm(dot)be>
To: pgsql-sql(at)postgresql(dot)org
Subject: change a field
Date: 2003-09-10 20:12:45
Message-ID: 5.2.1.1.0.20030910220528.015ac238@server04.site04.wtcm.be
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Martin Marques 2003-09-10 20:39:17 Re: how to vacum
Previous Message Peter Eisentraut 2003-09-10 19:46:43 Re: how to vacum