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

Problem In Trigger ... mutating

Featured Replies

بتاريخ:

قمت بعمل هذا التريجر

CREATE OR REPLACE TRIGGER check_salary
BEFORE INSERT OR UPDATE OF salary, job_id ON employees
FOR EACH ROW
WHEN (NEW.job_id <> 'AD_PRES')
DECLARE
v_minsalary 	employees.salary%TYPE;
v_maxsalary 	employees.salary%TYPE;
BEGIN SELECT 	MIN(salary), MAX(salary)
INTO v_minsalary, v_maxsalary
FROM employees WHERE job_id = :NEW.job_id;
IF :NEW.salary < v_minsalary OR :NEW.salary > v_maxsalary THEN
RAISE_APPLICATION_ERROR(-20505,'Out of range');
END IF;
END;
/





وبعدين عملت الكود ده


UPDATE employees SET salary = 3400 WHERE last_name¬ = 'Stiles';




بس للاسف طلعتلي الerror دي

SQL> UPDATE employees SET salary = 3400 WHERE last_name = 'Stiles';
UPDATE employees SET salary = 3400 WHERE last_name = 'Stiles'
        *
ERROR at line 1:
ORA-04091: table HR.EMPLOYEES is mutating, trigger/function may not see it
ORA-06512: at "HR.CHECK_SALARY", line 5
ORA-04088: error during execution of trigger 'HR.CHECK_SALARY'





ارجو المساعده وجزاكم الله كل خير

بتاريخ:

يمكنك استخدام خاصية البحث بالمنتدى ... للبحث عن حل مشكلة ال MUTATING

منها
إضغط هنا : مشاركة سابقة بالمنتدى

المقصود ب MUTATING TABLE
انه عند عمل تريجر مثلا BEFORE UPDATE علي تابل
اذا كنت تقوم بسيليكت من نفس اتابل الذي تعمل فيه الابديت
هيطلع ايرور و قت التفيذ
ان هذا التابل MUATATING و لا يمكن ان تعمل منه سيليكت
اي انه يتغير
لذلك لا يمكن عمل اي سيليكت من نفس التابل اللي عليه التريجر

فهى باختصار انك اذا انشات trigger وعايزة يعمل fire عندما تريد مثلا عمل insert ثم قمت بكتابة جملة dml فى ال trigger body فان هذا سيؤدى لظهور رسالة خطا mutating table اى ان هناك تداخل او عدم تساق حيث لا يمكن عمل insert فى جدول وعمل select فى نفس الجدول وفى نفس الوقت


ORA-04091 table string.string is mutating, trigger/function may not see it
Cause: A trigger (or a user defined PL/SQL function that is referenced in this
statement) attempted to look at (or modify) a table that was in the middle of
being modified by the statement which fired it.
Action: Rewrite the trigger (or function) so it does not read that table
.



اليك هذا الرابط
إضغط هنا Avoiding Mutating Tables

بتاريخ:

جزاك الله خيرا اخ امجد, فعلا رد وافي

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

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

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

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

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

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.