pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedchange a field
4+ messages / 4 participants
[nested] [flat]
* change a field
@ 2003-09-10 20:12 Patrick Meylemans <Patrick.Meylemans@wtcm.be>
0 siblings, 3 replies; 4+ messages in thread
From: Patrick Meylemans @ 2003-09-10 20:12 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: change a field
@ 2003-09-15 00:03 Peter Eisentraut <peter_e@gmx.net>
parent: Patrick Meylemans <Patrick.Meylemans@wtcm.be>
2 siblings, 0 replies; 4+ messages in thread
From: Peter Eisentraut @ 2003-09-15 00:03 UTC (permalink / raw)
To: Patrick Meylemans <Patrick.Meylemans@wtcm.be>; +Cc: pgsql-sql
Patrick Meylemans writes:
> What is the best way to solve this problem ?
Show us your code.
--
Peter Eisentraut peter_e@gmx.net
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: change a field
@ 2003-09-15 04:57 A.Bhuvaneswaran <bhuvan@symonds.net>
parent: Patrick Meylemans <Patrick.Meylemans@wtcm.be>
2 siblings, 0 replies; 4+ messages in thread
From: A.Bhuvaneswaran @ 2003-09-15 04:57 UTC (permalink / raw)
To: Patrick Meylemans <Patrick.Meylemans@wtcm.be>; +Cc: pgsql-sql
> 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.
You can easily accomplish this in a BEFORE trigger. It is applicable for
both insert & update.
regards,
bhuvaneswaran
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: change a field
@ 2003-09-15 14:27 Bruno Wolff III <bruno@wolff.to>
parent: Patrick Meylemans <Patrick.Meylemans@wtcm.be>
2 siblings, 0 replies; 4+ messages in thread
From: Bruno Wolff III @ 2003-09-15 14:27 UTC (permalink / raw)
To: Patrick Meylemans <Patrick.Meylemans@wtcm.be>; +Cc: pgsql-sql
On Wed, Sep 10, 2003 at 22:12:45 +0200,
Patrick Meylemans <Patrick.Meylemans@wtcm.be> wrote:
>
> What is the best way to solve this problem ?
The best way is probably with a view.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2003-09-15 14:27 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-10 20:12 change a field Patrick Meylemans <Patrick.Meylemans@wtcm.be>
2003-09-15 00:03 ` Peter Eisentraut <peter_e@gmx.net>
2003-09-15 04:57 ` A.Bhuvaneswaran <bhuvan@symonds.net>
2003-09-15 14:27 ` Bruno Wolff III <bruno@wolff.to>
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