pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Patrick Meylemans <Patrick.Meylemans@wtcm.be>
To: pgsql-sql@postgresql.org
Subject: change a field
Date: Wed, 10 Sep 2003 22:12:45 +0200
Message-ID: <5.2.1.1.0.20030910220528.015ac238@server04.site04.wtcm.be> (raw)

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




view thread (4+ messages)  latest in thread

Message-ID: <5.2.1.1.0.20030910220528.015ac238@server04.site04.wtcm.be>
Permalink:  ../5.2.1.1.0.20030910220528.015ac238@server04.site04.wtcm.be/
Also on:    postgresql.org/message-id/5.2.1.1.0.20030910220528.015ac238@server04.site04.wtcm.be

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: Patrick.Meylemans@wtcm.be
  Subject: Re: change a field
  In-Reply-To: <5.2.1.1.0.20030910220528.015ac238@server04.site04.wtcm.be>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox