CREATE OR REPLACE TRIGGER emp_dep_sum_trg
 AFTER
   INSERT OR DELETE OR UPDATE OF salary
 ON employees
REFERENCING NEW AS NEW OLD AS OLD
declare
  v_sum_sal number;
  v_department_id number;
begin

update dep_sum d set sal_sum = (SELECT sum(employees.salary)
  FROM employees, dep_sum
 WHERE ((employees.department_id = dep_sum.department_id))
and employees.department_id = d.department_id);

/*
v_department_id := nvl(:new.department_id, :old.department_id);

SELECT sum(employees.salary) into v_sum_sal from employees
where department_id = v_department_id;

update dep_sum set sal_sum = v_sum_sal
where department_id = v_department_id;
*/
end;
/