Updating within Triggers

From: Jamie Deppeler <jamie(at)doitonce(dot)net(dot)au>
To: Postgresql-General <pgsql-general(at)postgresql(dot)org>
Subject: Updating within Triggers
Date: 2005-10-31 06:12:19
Message-ID: 4365B5C3.3080008@doitonce.net.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi trying to wtite a trigger to update summary fields in a seperate
table to do this i am planning on using trigger.
problem i have at the moment the update trigger doesnt seem to be
fireing but the insert works.

Trigger

CREATE TRIGGER "setSummary" AFTER INSERT OR UPDATE
ON "parts" FOR EACH ROW
EXECUTE PROCEDURE "material"();

function
CREATE OR REPLACE FUNCTION "partSumm" () RETURNS trigger AS
$body$
begin
update project
actualsummmatcost = (select sum(actualcost) from projects.material
where material."fkproject" = new.fkproject;),
actualsummmattotal = (select sum(actualcharge) from
projects.material where material."fkprojet" = new.fkproject;),
where project."primary" = new.fkproject;
return new;
end;
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Josh Rehman 2005-10-31 07:16:22 Re: [ANNOUNCE] PostgreSQL 8.1.0 Release Candidate 1
Previous Message CSN 2005-10-31 06:05:55 Re: PostgreSQL 8.1 vs. MySQL 5.0?