Re: Triggering from a specific column update

From: "Bob Pawley" <rjpawley(at)shaw(dot)ca>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Postgresql" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Triggering from a specific column update
Date: 2009-11-16 00:06:46
Message-ID: D701F44DF6B541678C6D15083487260A@desktop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm trying to trigger from an update.

However the trigger functions when any column has been updated.

I have columns pump1 and pump2 and column serial.

When pump1 is updated the trigger function performs properly. (one row is
returned)

When pump2 is updated the trigger function returns two rows )one row for
column pump1 and one for column pump2) I end up with two rows of pump1 and
one row of pump2.

If I write the function with a null such as --
If new.pump1 = 'True'
then
Insert into p_id.devices (p_id_id, process_id, fluid_id, status,
process_graphics_id, device_description)
select (p_id.processes.p_id_id), (p_id.processes.process_id),
(p_id.processes.fluid_id), ('Pump #1'), ('11'), ('Pump')
from p_id.processes
where new.pump1 = 'True'
and p_id.processes.pump2 is null;

it works fine returning what I want. However, when the serial column is
updated I get a return which includes pump1 and pump2 as well as the serial
column.

Hope this elucidates you?

Bob

----- Original Message -----
From: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Bob Pawley" <rjpawley(at)shaw(dot)ca>
Cc: "Postgresql" <pgsql-general(at)postgresql(dot)org>
Sent: Sunday, November 15, 2009 3:43 PM
Subject: Re: [GENERAL] Triggering from a specific column update

> "Bob Pawley" <rjpawley(at)shaw(dot)ca> writes:
>> "PostgreSQL does not support specific column updates in triggers."
>> I found this statement on a blog.
>
>> Is there a workaround for this?
>
> If you'd explain what you think that statement means, maybe we could
> help you ...
>
> regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Loyal 2009-11-16 00:42:43 Re: Experience with many schemas vs many databases
Previous Message Tom Lane 2009-11-15 23:43:25 Re: Triggering from a specific column update