Skip to Main Content

Backup the rows where the deleted using Database Triggers

994122Apr 14 2014 — edited Apr 14 2014

Hi all,

1)CREATE TABLE student1

  (

     no    NUMBER,

     name  VARCHAR2(10 byte),

     marks NUMBER

  )


I have inserted 10 records(1,2,3....10)


2)Created student1_history Table create table student1_history as select * from student1;

3)delete from student1

   where no=10

4)CREATE OR replace TRIGGER after_student1

  AFTER DELETE ON student1

  FOR EACH ROW

BEGIN

    INSERT INTO student1_history

                (no,

                 name,

                 marks)

    VALUES      (:old.no,

                 :old.name,

                 :old.marks);

END;


5) select * from student1_history

    no rows returned.


i have 2 tables as shown above, i deleted one row from student1 table and i have compile the Trigger , i want to store the deleted row in the student1_history Table


Can you please help


Comments
Post Details
Added on Apr 14 2014
7 comments
1,499 views