الانتقال إلى المحتوى
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.

ORA-04091: table HR.EMP1 is mutating, trigger

Featured Replies

بتاريخ:

عندي جدولين وليكن EMP1 and EMP2

بكل بساطة عاوز اذا عملت insert  في احدهم يروح ينفذ نفس جملة  Insert في الجدول الاخر والعكس صحيح "بشرط الا تتكرر الداتا" ... 

لو عملتها علي جدول واحد بتشتغل عادي ومش بيطلع اي ايرورو وبتتنفذ 100% .. لكن لما بطبقها علي الجدولين بيطلع ايرور mutating  اللي كلنا عارفينه .. حد عنده حل ؟ 

----------------------------TRIGGER 1---------------

CREATE OR REPLACE TRIGGER copy_data_emp1 
after insert on emp1
for each row
declare 
v_emp_id  number ; 
begin  
 select emp2.EMPLOYEE_ID
  into v_emp_id 
 from  emp2  
 where EMPLOYEE_ID  = :new.EMPLOYEE_ID ;  
 exception when no_data_found then 
INSERT INTO HR.emp2 (
   EMPLOYEE_ID, FIRST_NAME, LAST_NAME, 
   EMAIL, PHONE_NUMBER, HIRE_DATE, 
   JOB_ID, SALARY, COMMISSION_PCT, 
   MANAGER_ID, DEPARTMENT_ID) 
VALUES ( :new.EMPLOYEE_ID, :new.FIRST_NAME, :new.LAST_NAME, 
   :new.EMAIL, :new.PHONE_NUMBER, :new.HIRE_DATE, 
   :new.JOB_ID, :new.SALARY, :new.COMMISSION_PCT, 
   :new.MANAGER_ID, :new.DEPARTMENT_ID );
 
end;/

----------------------------------------------TRIGGer 2----------------------------------------------------------------------------------

CREATE OR REPLACE TRIGGER copy_data_emp2 
after insert on emp2
for each row
declare 
v_emp_id  number ; 
begin  
 select emp1.EMPLOYEE_ID
  into v_emp_id 
 from  emp1
 where emp1.EMPLOYEE_ID  = :new.EMPLOYEE_ID ;  
  exception when no_data_found then 
INSERT INTO HR.emp1 (
   EMPLOYEE_ID, FIRST_NAME, LAST_NAME, 
   EMAIL, PHONE_NUMBER, HIRE_DATE, 
   JOB_ID, SALARY, COMMISSION_PCT, 
   MANAGER_ID, DEPARTMENT_ID) 
VALUES ( :new.EMPLOYEE_ID, :new.FIRST_NAME, :new.LAST_NAME, 
   :new.EMAIL, :new.PHONE_NUMBER, :new.HIRE_DATE, 
   :new.JOB_ID, :new.SALARY, :new.COMMISSION_PCT, 
   :new.MANAGER_ID, :new.DEPARTMENT_ID );
 
end;
/

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

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

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

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

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

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.