Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

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


This post has been answered by Jjun.Tan on Apr 14 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 12 2014
Added on Apr 14 2014
7 comments
2,917 views