If I have a trigger before updating in the CANINES table that sets the timestamp now () column, and DOGS inherits from CANINES, when the DOGS row is updated, does the CANINES update trigger fire? This is not the case in my tests, so I suspect the answer is “No,” but maybe I didn’t do everything right:
create table canines
(
lastupdate timestamp with time zone default now()
);
CREATE OR REPLACE FUNCTION stamp_lastupdate_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.lastupdate = now();
RETURN NEW;
END;
$$ language 'plpgsql';
CREATE TRIGGER TRG_CANINES_BU BEFORE UPDATE
on CANINES FOR EACH ROW EXECUTE PROCEDURE
stamp_lastupdate_column();
create table dogs
(id int primary key,
breed varchar(25)
) inherits (CANINES);
insert into dogs(id, breed) values(1, 'sheltie');
select * from dogs;
update dogs set breed = 'Sheltie/Shetland Sheepdog' where id = 1;
select * from dogs;
source
share