我有一张projects
表。我希望在statusupdate
表中进行任何修改时更新projects
表。
statusupdate
表中最多有20个程序代码。这是我到目前为止工作的触发器,但它显示#error没有别的
DELIMITER $$
CREATE TRIGGER statuss AFTER INSERT,Update ON projects
FOR EACH ROW
begin
DECLARE ongoing int default 0;
DECLARE completed int default 0;
DECLARE pending int default 0;
Set @ongoing =(select count(ProjStatus) from projects where ProjStatus='Ongoing');
Set @completed =(select count(ProjStatus) from projects where ProjStatus='Completed');
Set @pending =(select count(ProjStatus) from projects where ProjStatus='Pending');
update statusupdate
(Prov ,Ongoing,Completed,Pending )
values
(OLD.ProvId,@ongoing,@completed,@pending)
where ProgCode=OLD.ProgramCode
end $$
DELIMITER ;