I'm having an issue with SQL/Oracle 10g when it comes to create a statement level trigger. What I'm trying to achieve with this trigger is to delete a practical class when enrollment of students is < 5. Below is what I've written:
CREATE OR REPLACE TRIGGER delete_prac
AFTER UPDATE ON studEnrol
BEGIN
DELETE FROM pracList
WHERE Practical IN (
SELECT Practical
FROM studEnrol
GROUP BY Practical
HAVING COUNT(Practical) < 5);
END delete_prac;
The error I'm getting however is:
ORA-04091: pracList table is mutating, trigger/function may not see it
I've looked into this error and the suggestions that arose were to include the :new and :old keywords, but I don't know how I would do that.
Any help is appreciated!
Thanks.
EDIT: Forgot to add which table was mutating, its the pracList table EDIT2: Changed it to a statement level trigger and the mutating table still occurs with pracList