CREATE OR REPLACE TRIGGER DTULTATU_PREPPRAPAD
BEFORE INSERT OR UPDATE OR DELETE
ON PREPPRAPAD FOR EACH ROW

DECLARE
V_CDPRATO      PREPPRAPAD.CDPRATO%TYPE;
V_CDFILAUXPRAT PREPPRAPAD.CDFILAUXPRAT%TYPE;

BEGIN
   IF DELETING THEN
      V_CDPRATO      := :OLD.CDPRATO;
      V_CDFILAUXPRAT := :OLD.CDFILAUXPRAT;
   ELSE
      V_CDPRATO      := :NEW.CDPRATO;
      V_CDFILAUXPRAT := :NEW.CDFILAUXPRAT;
   END IF;

   UPDATE
      PRATO
   SET
      DTULTATURECE = SYSDATE
   WHERE
      (CDPRATO      = V_CDPRATO) AND
      (CDFILAUXPRAT = V_CDFILAUXPRAT);
END;
/
