PLSQL

PLSQL


1. PLSQL Trigger


CREATE OR REPLACE TRIGGER XX_TEST_TRIGGER AFTER
  INSERT OR
  UPDATE OR
  DELETE ON XX_TEST_TABLE REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW DECLARE l_transaction VARCHAR2(10);
  BEGIN
    -- determine the transaction type
    l_transaction :=
    CASE
    WHEN INSERTING THEN
    'CREATED'
    WHEN UPDATING THEN
      'UPDATE'
    WHEN DELETING THEN
      'DELETE'
    END;
    -- insert a row into the audit table
    INSERT
    INTO XX_TEST_TABLE1
      (
        INVOICE_NUMBER,
        ATTRIBUTE1,
        ATTRIBUTE2
      )
      VALUES
      (
        :NEW.INVOICE_NUMBER,
        l_transaction,
        :OLD.INVOICE_NUMBER
      );
    --COMMIT;

  END;

Post a Comment

0 Comments