RE: How to insert record into table which is deleted from another table?

Answered

How to insert record into table which is deleted from another table?

sid Asked on September 17, 2017 in Azure SQL Database.
Add Comment
1 Answers
Best answer

To insert records into table deleted from another table for that we need to create trigger witch delete records from one table and insert in to another table. see below PL / SQL code

 

 

create or replace trigger ondel
after delete on dept for each row
declare
dno dept.deptno%type ;
dname dept.dname%type;
dloc dept.loc%type;

begin
–select dname,loc into dname,dloc from dept where deptno=dno;
–dbms_output.put_line(‘Record to be Deleted’);
–dbms_output.put_line(dname||chr(13)||dloc||dno);
–delete from emp where deptno=dno;
dbms_output.put_line(‘Deleted …..’);
insert into depdup values(:old.deptno,:old.dname,:old.loc);
dbms_output.put_line(‘Inserted’);
end;

 

Answered on September 17, 2017.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.