## Database triggers can be "tuned" in a number of ways. ## Move the trigger text to a stored procedure CREATE or REPLACE TRIGGER Update_Sum_T1 After Update OR INSERT OR DELETE On EMP For Each Row BEGIN Update_Sum_Prc (:OLD.salary, :NEW.Salary, :NEW.rowid); END; ## Replace the trigger functionality with DDL table constraints ## and database RI CREATE or REPLACE TRIGGER Validate_EMP_T1 After Insert On EMP For Each Row DECLARE CURSOR C1 IS SELECT ‘x’ FROM dept WHERE dept_no = :NEW.dept_no; -- xdummy varchar2(1); BEGIN if :NEW.salary <= 0 then raise form_application_error ( -20000, 'Salary must be greater than $0.00’); end if; -- if :NEW.salary > 100,000 and :NEW.sal_grade < 10 then raise form_application_error ( -20001, ‘Salary cannot excede 100,000 for theis Job Grade’); end if; -- OPEN C1; FETCH C1 into xdummy; if C1%notfound then raise form_application_error ( -20002, ‘Invalid Department Number Entered’); end if; -- :NEW.last_upd_date := sysdate; :NEW.last_upd_user := user; END; ## Would Be Better Coded as :- Create table EMP ( emp_no number(6) not null, .... dept_no number(4) constraint EMP_dept_FK references dept(deptno), salary number(12,2) check (salary > 0), sal_grade number(2), last_upd_date date default sysdate not null, last_upd_user varchar2(10) default user not null, constraint check_sal check (salary < 100000 or sal_grade >= 10) )