Example of trigger using procedure language

Example of trigger using procedure language


 CREATE OR REPLACE TRIGGER Trig_test  
 AFTER INSERT  
 ON EMP1  
 FOR EACH ROW  
 DECLARE  
 PRAGMA AUTONOMOUS_TRANSACTION;  
 BEGIN  
 test_T; -- Test_T is a Procedure  
 commit;  
 END Trig_test  

 create or replace procedure test_T  
 AS  
 declare  
 v_empno emp.EMPNO%type;  
 cursor c1 is  
 select empno from emp1  
 where empno is null;  
 BEGIN  
 open c1;loop  
 fetch c1 into v_empno;  
 exit when c1%notfound;  
 update emp1 set empno = empno_seq.nextval where empno is null;  
 end loop;  
 close c1;  
 Exception when others then null;  
 end;