بتاريخ: 9 يونيو 200620 سنة comment_71640 ما معنى INSTEAD OF و هل يمكن لل trigger ان يرجع قيمه ؟؟؟؟؟؟؟؟ CREATE OR REPLACE TRIGGER manager_info_insert INSTEAD OF INSERT ON manager_info REFERENCING NEW AS n ايهاب وجدى تقديم بلاغ
بتاريخ: 11 يونيو 200620 سنة comment_71835 إليك رد كافي شافي منقووووووولاذا كان هناك لبس في الفهم ممكن أوضحلك Sometimes you need to update or insert into a view. But say your view has multiple tables like the outemp view: create or replace view outemp as select EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,dname from emp e ,dept d where d.deptno = e.deptno Instead of updating the view, you can create a trigger which overrides the default operation of the update statement: create or replace trigger update_emp_thru_outemp_view instead of update on outemp referencing new as new begin update emp set ename = :new.ename, empno = :new.empno, job = :new.job, mgr = :new.mgr, hiredate = :new.hiredate, sal = :new.sal, comm = :new.comm, deptno = ( select deptno from dept where dname = :new.dname ) where empno = :old.empno; if ( sql%rowcount = 0 ) then raise_application_error ( -20001, 'Error updating the outemp view !!!' ); end if; end; Then, you can update this from SQL*Plus as you would a table: scott@fis> update outemp set ename = 'C Farmer' where ename = 'FARMER'; 1 row updated. scott@fis> select * from emp where ename = 'C Farmer'; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- 3456 C Farmer DBA 7839 01-JUL-02 4000 4 40 1 row selected. You can get some strange errors from the update statement if you try to update with invalid data: scott@fis> update outemp set dname = 'dkjsk' where ename = 'C Farmer'; update outemp set dname = 'dkjsk' where ename = 'C Farmer' * ERROR at line 1: ORA-01407: cannot update ("SCOTT"."EMP"."DEPTNO") to NULL ORA-06512: at "SCOTT.UPDATE_EMP_THRU_OUTEMP_VIEW", line 2 ORA-04088: error during execution of trigger 'SCOTT.UPDATE_EMP_THRU_OUTEMP_VIEW' scott@fis≫ update outemp set dname = 'OPERATIONS' where ename = 'C Farmer'; 1 row updated. تقديم بلاغ
بتاريخ: 12 أغسطس 200619 سنة comment_76423 instead of معناها بدلاً عن معنى ذلك انك تلغي عملية الادخال insert او عملية التعديل update وبدلاً عن ذلك تستخدم التعليمة البرمجية التي تريدها وكما في المثال السابق الذي ذكره الاخ ابو سراج عندما نريد عمل اضافة على الـ view الذي يتكون من اكثر من جدول فاننا نستخدم هذا trigger instead of وبذلك يمكننا الاضافة في كل من جدول emp وجدول dept تقديم بلاغ
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.