-- ====================================================================
-- TRG_A_DEVO_REPLICA_MGMT_MOPDB Trigger Definition
-- ====================================================================
-- Purpose: Audit trigger for A_DEVO_REPLICA_MGMT_MOPDB operations
-- Source: new_EXP.sql export from production database
-- ====================================================================

CREATE OR REPLACE EDITIONABLE TRIGGER "CT_MRDS"."TRG_A_DEVO_REPLICA_MGMT_MOPDB" 
AFTER INSERT OR UPDATE OR DELETE
   ON CT_MRDS.A_DEVO_REPLICA_MGMT_MOPDB
  FOR EACH ROW
DECLARE
   vAction VARCHAR2(100);
BEGIN
   IF INSERTING THEN
      vAction := 'INSERT';
   ELSIF UPDATING THEN
      vAction := 'UPDATE';
   ELSIF DELETING THEN
      vAction := 'DELETE';
   END IF;
   INSERT INTO
      CT_MRDS.A_DEVO_REPLICA_MGMT_LOG (OWNER, TABLE_NAME, TABLE_ALIAS,
                                           LAST_RUN_ID, LAST_START_TIME, LAST_END_TIME,
                                           LAST_STATUS, SAVE_MODE, PARTITION_COLUMN,
                                           MAX_THREADS, LAST_PROCESSED_KEY, ACTION,
                                           LOG_DATE, LOG_SOURCE)
                                   VALUES (:NEW.OWNER, :NEW.TABLE_NAME, :NEW.TABLE_ALIAS,
                                           :NEW.LAST_RUN_ID, :NEW.LAST_START_TIME, :NEW.LAST_END_TIME,
                                           :NEW.LAST_STATUS, :NEW.SAVE_MODE, :NEW.PARTITION_COLUMN,
                                           :NEW.MAX_THREADS, :NEW.LAST_PROCESSED_KEY, vAction,
                                           SYSDATE, 'MOPDB');
END;

/