## Database triggers can be "improved" by "exploiting" the WHEN clause


   CREATE OR REPLACE TREIGGERE Validate_EMP_T1
   After Insert	 OR Update 
   On EMP For Each Row
   BEGIN
     if	UPDATING then
	if :NEW.salary 	!= :OLD.salary
	or :NEW.dept_no	!= :OLD.dept_no then
	   .
	end if;
     elsif INSERTING then
	if :NEW.salary	!= 0 then
	   .
	end if;
     end if;
   END;


## Would be better coded as :-

   CREATE OR REPLACE TRIGGER Validate_EMP_T1 on EMP
   After Insert	 OR Update  
   On EMP For Each Row
   WHEN ( UPDATING  and (  NEW.salary  != OLD.salary 
                        or NEW.dept_no != OLD.dept_no )
       or INSERTING and    NEW.salary  != 0             )
   BEGIN
     if	UPDATING then
	.
     elsif INSERTING then
	.
     end if;
   END;
