Friday, March 9, 2018

PL/SQL - TRIGGER with Example Programs

First, create two tables for the same structure.
   create table empl(name varchar2(50),company       varchar2(50),join_date date);
   create table employee as select * from empl where 1 = 1;

create or replace trigger insert_empl
after insert or update or delete
on empl
for each row
declare
      v_name varchar2(30);
begin
     if inserting then
         insert into employee values(:new.name,:new.company,sysdate);
     end if;
end;


Output :
       insert into empl values('suriya','abc',sysdate);
      select * from employee;
           suriya abc 09-MAR-18.

No comments:

Post a Comment