Posts Oracle plsql Part 12
Post
Cancel

Oracle plsql Part 12

  • creating a view
1
2
3
4
create view rahul_emp_details
as
select e.empno,e.ename,e.hiredate,d.deptno,d.dname from rahul_emp e,rahul_dept d
where e.deptno = d.deptno
  • create instead of trigger on the view created above
1
2
3
4
5
6
7
8
9
create or replace trigger rahul_emp_details_insert
--Instead of insert on rahul_emp_details (view name)
Instead of insert on rahul_emp_details 
for each row
begin
insert into rahul_emp(EMPNO,ENAME,HIREDATE,DEPTNO) values(:new.empno,:new.ename,:new.hiredate,:new.deptno);
insert into rahul_dept(deptno,dname)
values (:new.deptno,:new.dname);
end;
  • insert into view to trigger instead of trigger
1
insert into rahul_emp_details(empno,ename,hiredate,deptno,dname) values(1234,'rc',sysdate,50,'ee');
  • enable disable trigger
1
2
3
4
5
# Alter trigger trigger_name  disable | enable

# Alter table table_name   disable | enable  all triggers

Alter trigger trigger_name compile
This post is licensed under CC BY 4.0 by the author.