I want to create a trigger that can modify or insert a date in my table \"contracts\":
\"If a client with a current contract signs a new one, the end date Of the previou
You want something like this:
CREATE OR REPLACE TRIGGER TRIGGER_D
BEFORE
INSERT OR UPDATE ON CONTRACTS
FOR EACH ROW
DECLARE
BEGIN
UPDATE CONTRACTS
SET ENDDATE = :NEW.STARTDATE - INTERVAL '1' DAY
WHERE CLIENTID = :NEW.CLIENTID
AND ENDDATE > :NEW.STARTDATE
AND STARTDATE < :NEW.STARTDATE;
END;
However, it is updating the table that the trigger is monitoring and it seems likely that the trigger will cause updates that will invoke the trigger again and get a mutating table error.
You might be better to wrap your business logic in a stored procedure where it can perform the update on the previous rows and then do the insert/update. Then, rather than performing DML statements directly on the table instead invoke the stored procedure.