Sie sind auf Seite 1von 4

call by value :=============== CREATE OR REPLACE Procedure copy_proc (Y number, X out number) is n number; begin X := 123; n :=x/0; END;

/ declare A number; begin A :=100; copy_proc(0,A); exception when others then dbms_output.put_line(nvl(A)); null; END; / 100 call by reference :==================== CREATE OR REPLACE Procedure nocopy_proc (Y number, X out nocopy number) is n number; begin X := 123; n :=x/0; END; / declare A number; begin A :=100; nocopy_proc(0,A); exception when others then dbms_output.put_line(nvl(A)); null; END; / 123 ======================================================================== ======================================================================== INSTEAD OF INSERT :================= SQL> select * from emp_dtl; EMPNO ENAME DEPTNO ---------- ---------------------------------------------------------------------

-------------------10001 S PAL 10 10002 G PAL 10 10003 M KAR 20 10004 G DUTTA 30 SQL> SELECT * FROM DEPT_DTL; DEPTNO ---------10 20 30 DNAME ---------IT CSC HARDWARE

SQL> SELECT * FROM EMP_DEPT_DTL (VIEW); EMPNO ENAME DNAME ---------- ---------------------------------------------------------------------------------------10001 S PAL IT 10002 G PAL IT 10003 M KAR CSC 10004 G DUTTA HARDWARE SQL> insert into emp_dept_dtl values(1007,'G SSS','HARDWARE'); insert into emp_dept_dtl values(1007,'G SSS','HARDWARE') * ERROR at line 1: ORA-01776: cannot modify more than one base table through a join view

INSTEAD IF INSERT :--------------------SQL> ED Wrote file afiedt.buf 1 2 3 4 5 6 7 8 9 10 11 12 create or replace trigger insteadofInsert instead of insert on emp_dept_dtl for each row declare v_deptno dept_dtl.deptno%type; begin select deptno into v_deptno from dept_dtl where dname=:new.dname; insert into emp_dtl values(:new.empno,:new.ename,v_deptno); exception

13 when others then 14 raise_application_error(-20001,'Please provide correct dept nam e'); 15* end; SQL> / Trigger created.

INSTEAD OF UPDATE: -----------------SQL> update EMP_DEPT_DTL set dname='CSC' where empno=10001; update EMP_DEPT_DTL set dname='CSC' where empno=10001 * ERROR at line 1: ORA-01779: cannot modify a column which maps to a non key-preserved table

SQL> update EMP_DEPT_DTL set ename='MD',dname='IT' where empno=10001; ERROR at line 1: ORA-01779: cannot modify a column which maps to a non key-preserved table TO SOLVE:---------SQL> ed Wrote file afiedt.buf 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 create or replace trigger insteadOfUpdate instead of update on emp_dept_dtl declare v_deptno dept.deptno%type; begin begin if updating('empno') then update emp_dtl set empno=:new.empno where empno=:old.empno; end if; exception when others then raise_application_error(-20001,'Please check Empno'); end; begin if updating('ename') then update emp_dtl set ename=:new.ename where empno=:old.empno; end if; exception when others then raise_application_error(-20002,'Please check Ename'); end; begin if updating('dname') then select deptno into v_deptno from

28 dept_dtl where 29 dname=:new.dname; 30 update emp_dtl set deptno=v_deptno 31 where empno=:old.empno; 32 end if; 33 exception 34 when others then 35 raise_application_error(-20003,'Please check deptno'); 36 end; 37 exception 38 when others then 39 raise_application_error(-20004,'Please check and Confirm!!!'); 40* end; SQL> / Trigger created.

Das könnte Ihnen auch gefallen