Hi
I have a requirement to Create a trigger which triggers before insert to the table, In this trigger it should check for a column's value, if that value already exists then that row must be deleted and latest row should be added.
CREATE OR REPLACE TRIGGER REMOVEDUPLICATES
BEFORE INSERT ON TestTable
REFERENCING OLD AS OL NEW AS NW
FOR EACH ROW
/*WHEN (ID = :NW.ID) */
BEGIN
DELETE FROM TestTable WHERE ID = :NW.ID;
END;
This trigger is giving below exceptions.
ORA-06512: at "REMOVEDUPLICATES ", line 2
ORA-04088: error during execution of trigger 'REMOVEDUPLICATES'
java.sql.BatchUpdateException: ORA-04091: table TestTable is mutating, trigger/function may not see it
Can some one advice what to do in this case.