# DDL

##

    CREATE OR REPLACE TRIGGER trg_UID_tab1
    AFTER INSERT OR UPDATE
    ON tab1
    FOR EACH row
    /* This is a sample of an INSERT/UPDATE
       trigger which populates column F1 in table TAB1
       on INSERT and reset column F2 on update */
    DECLARE
      lv_next_val NUMBER;
    BEGIN
      IF updating THEN
         IF :old.f2=pkg1.gc_magic_date THEN
            :NEW.f2 := TRUNC(SYSDATE);
         END IF;
       ELSIF inserting THEN
         lv_next_val := pkg1.fcn_seq1_get_next;
         :NEW.f1 := lv_next_val;
         :NEW.f2 := TRUNC(SYSDATE);
      END IF;
    END;
    /