Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mutating table error...
Message
General information
Forum:
Oracle
Category:
Triggers, Sequences and Stored Procedures
Miscellaneous
Thread ID:
00654702
Message ID:
00655780
Views:
41
George,

Yes, this is the problem. Some of the triggers fired by the updates in the trigger check to make sure the parent ID exists in the employee table.
CREATE OR REPLACE TRIGGER "PAYROLL TEST"."TRIG_BIUD_EMP_TIME" 
    BEFORE INSERT OR 
    DELETE OR 
    UPDATE OF "DATEFROM", "DATETO", "EMPLOYEEID" 
    ON "PAYROLL TEST"."EMP_TIME" 
    FOR EACH ROW 
    DECLARE RecordCount NUMBER;
BEGIN   
  /* PREVENT INSERTS AND UPDATES IF NO MATCHING KEY IN 'employee' */ 
  IF (UPDATING AND :old.employeeid != :new.employeeid) OR INSERTING 
  THEN     
    SELECT COUNT(*) 
    INTO RecordCount 
    FROM employee 
    WHERE (employee.id = :new.employeeid);
    IF RecordCount = 0 
    THEN         
      raise_application_error(-20003, 'Employee ID does not exist in the employee table.');
    END IF;
  END IF;
END;
Is there a way to determine how a trigger is being called? If I know the trigger is being fired by "TRIG_BIUD_EMPLOYEE" trigger I could bypass testing for the employeeid in the employee table.


>You are modifying multiple tables here so several triggers may be firing. You will need to look at all the triggers to see if they are also doing updates to any of these tables or related constraining tables.
>
>>I am getting an error:
>>
>>PAYROLL TEST.EMPLOYEE is mutating, trigger/function may not see it ORA-0651: at "PAYROLL TEST.TRIG_BIUD_EMP_TIME",line 6
>>
>>Anyone have suggests how to correct this error?
>>
>>The trigger is:
>>
>>
>>CREATE OR REPLACE TRIGGER "PAYROLL TEST"."TRIG_BIUD_EMPLOYEE"
>>AFTER INSERT OR
>>DELETE OR
>>UPDATE OF "ID"
>>ON "PAYROLL TEST"."EMPLOYEE"
>>FOR EACH ROW
>>DECLARE RecordCount NUMBER;
>>BEGIN
>>IF UPDATING AND :old.id != :new.id
>>THEN
>>/* CASCADE UPDATES TO Pay Rate History */
>>UPDATE pay_rate
>>SET pay_rate.employeeID = :new.id
>>WHERE pay_rate.employeeID = :old.id;
>>
>>/* CASCADE UPDATES TO Employee Future Activities */
>>UPDATE emp_future
>>SET emp_future.employeeID = :new.id
>>WHERE emp_future.employeeID = :old.id;
>>
>>/* CASCADE UPDATES TO Employee History Info */
>>UPDATE emp_history
>>SET emp_history.employeeID = :new.id
>>WHERE emp_history.employeeID = :old.id;
>>
>>/* CASCADE UPDATES TO Employee License Table */
>>UPDATE emp_license
>>SET emp_license.employeeID = :new.id
>>WHERE emp_license.employeeID = :old.id;
>>
>>UPDATE emp_time
>>SET emp_time.employeeID = :new.id
>>WHERE emp_time.employeeID = :old.id;
>>END IF;
>>/* PREVENT DELETES IF DEPENDENT RECORDS IN Pay Rate History */
>>IF DELETING
>>THEN
>>SELECT COUNT(*)
>>INTO RecordCount
>>FROM pay_rate
>>WHERE (pay_rate.EmployeeID = :old.id);
>>IF RecordCount > 0
>>THEN
>>raise_application_error(-20002, 'Cannot delete record. Pay rates have been found for this employee.');
>>END IF;
>>
>>DELETE FROM emp_future
>>WHERE emp_future.employeeID = :old.id;
>>
>>DELETE FROM emp_history
>>WHERE emp_history.employeeID = :old.id;
>>
>>DELETE FROM emp_license
>>WHERE emp_license.employeeID = :old.id;
>>
>>DELETE FROM emp_time
>>WHERE emp_time.employeeID = :old.id;
>>END IF;
>>END;
>>
Heavy Metal Pedal - click with care
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform