SET TERM ^ ;



CREATE OR ALTER TRIGGER PROCESSOS_MINERAR_DATAS_BIU10 FOR PROCESSOS_MINERAR
ACTIVE BEFORE INSERT OR UPDATE POSITION 10
AS
BEGIN
  /* Trigger text */
  IF ((OLD.STATUS IS DISTINCT FROM NEW.STATUS) AND
      (NEW.STATUS IS NOT NULL)) THEN
  BEGIN
    IF (NEW.STATUS = 1) THEN
    BEGIN
      NEW.DATA_ENVIO = CURRENT_TIMESTAMP;
    END
    ELSE
    IF (NEW.STATUS >= 2) THEN
    BEGIN
      IF (OLD.STATUS IS NOT DISTINCT FROM NEW.STATUS) THEN
        NEW.DATA_ENVIO = CURRENT_TIMESTAMP;
      NEW.DATA_RETORNO = CURRENT_TIMESTAMP;
    END
  END
END
^
SET TERM ; ^