CREATE OR REPLACE TRIGGER "CINEMA"."TRG_ORA_VENDITE" BEFORE
INSERT
OR UPDATE OF "IDBIGLIETTO", "IDCALEND", "IDCASSA", "IDVEND", "NUM_BIGL", "TIPO", "VALUTA" ON "CINEMA"."VENDITE" FOR EACH ROW
DECLARE 
    iDate DATE; 
BEGIN 
    IF INSERTING THEN 
        :new.DATA_AGG := SYSDATE; 
    END IF;
    IF UPDATING THEN 
        IF :old.DATA_AGG IS NULL THEN 
          :new.DATA_AGG:= SYSDATE; 
       END IF;
       IF :old.NUM_BIGL = 0 THEN 
          :new.DATA_AGG:= SYSDATE; 
       END IF;       
      END IF; 
END;
