الانتقال إلى المحتوى
View in the app

A better way to browse. Learn more.

مجموعة مستخدمي أوراكل العربية

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ما معنى INSTEAD OF

Featured Replies

بتاريخ:

ما معنى INSTEAD OF و هل يمكن لل trigger ان يرجع قيمه ؟؟؟؟؟؟؟؟

CREATE OR REPLACE TRIGGER manager_info_insert
INSTEAD OF INSERT ON manager_info
REFERENCING NEW AS n



ايهاب وجدى

بتاريخ:

إليك رد كافي شافي منقووووووول

اذا كان هناك لبس في الفهم ممكن أوضحلك

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.

بتاريخ:
  • كاتب الموضوع

مشكور اخىىىىىىىىىىىىىى

ايهاب وجدى

  • بعد 1 شهر...
بتاريخ:

instead of معناها بدلاً عن معنى ذلك انك تلغي عملية الادخال insert او عملية التعديل update وبدلاً عن ذلك تستخدم التعليمة البرمجية التي تريدها وكما في المثال السابق الذي ذكره الاخ ابو سراج عندما نريد عمل اضافة على الـ view الذي يتكون من اكثر من جدول فاننا نستخدم هذا trigger instead of وبذلك يمكننا الاضافة في كل من جدول emp وجدول dept

بتاريخ:
  • كاتب الموضوع

شكرآ اخى

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية

Account

Navigation

البحث

إعداد إشعارات المتصفح الفورية

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.