CREATE TRIGGER TBMDF_NF_B09I FOR TBMDF_NF
ACTIVE BEFORE INSERT POSITION 9
AS
DECLARE VARIABLE HISTORICO VARCHAR(500);
BEGIN
  HISTORICO = '';

  IF(NEW.ID > 0) THEN
  BEGIN
    HISTORICO = HISTORICO||'NOTA FISCAL '||NEW.NF_ID || ' INCLUIDA';
  END

  IF(HISTORICO <> '') THEN
  BEGIN
    EXECUTE PROCEDURE SPI_HISTORICO('TBMDF', NEW.MDF_ID, HISTORICO);
  END
END;