PL/SQL Trigger

create table employee (id number,name varchar2(20),designation varchar2(20),salary number);

create table employee_history (id number,name varchar2(20),designation varchar2(20),salary number);

creating trigger
====================================================================
 create or replace trigger employee_history
        before insert or update or delete on employee
        for each row
        begin
        if inserting then
       dbms_output.put_line('record inserting');
        end if;
      if deleting then
        insert into employee_history values(:old.id,:old.name,:old.designation,:old.salary);
      end if;
      if updating then
      dbms_output.put_line('updating');
      end if;
    end;
   /


by above code when you delete a row from employee automatically that will be backed up in employee_history table

Comments

Popular posts from this blog

Git Commands With Output Log

Java Interview Preparation (conceptual)

Java 8 Function Interface