CREATE TRIGGER TTBFERRAMENTARIA_ITEM_B02I FOR TBFERRAMENTARIA_ITEM
ACTIVE BEFORE INSERT POSITION 9
AS
declare variable historico varchar(500);
BEGIN
  historico = '';
  IF(NEW.ID > 0) then
  BEGIN
    historico = historico||' Item incluido:'||NEW.ID;
  END

  IF(HISTORICO <> '') then
  BEGIN
    execute procedure spi_historico('TBFERRAMENTARIA',NEW.FERRAMENTARIA_ID,historico);
  END
END;

CREATE TRIGGER TTBFERRAMENTARIA_ITEM_B01D FOR TBFERRAMENTARIA_ITEM
ACTIVE BEFORE DELETE POSITION 9
AS
declare variable historico varchar(500);
BEGIN
  historico = '';
  IF(OLD.ID > 0) then
  BEGIN
    historico = historico||' Item excluido:'||OLD.ID;
  END

  IF(HISTORICO <> '') then
  BEGIN
    execute procedure spi_historico('TBFERRAMENTARIA',OLD.FERRAMENTARIA_ID,historico);
  END
END;

CREATE TRIGGER TTBFERRAMENTARIA_B05I FOR TBFERRAMENTARIA
ACTIVE BEFORE INSERT POSITION 9
AS
declare variable historico varchar(500);
BEGIN
  historico = '';
  IF(NEW.ID > 0) then
  BEGIN
    historico = historico||' Reg.Incluido';
  END

  IF(HISTORICO <> '') then
  BEGIN
    execute procedure spi_historico('TBFERRAMENTARIA',NEW.ID,historico);
  END
END;

CREATE TRIGGER TTBFERRAMENTARIA_B02D FOR TBFERRAMENTARIA
ACTIVE BEFORE DELETE POSITION 9
AS
declare variable historico varchar(500);
BEGIN
  historico = '';
  IF(OLD.ID > 0) then
  BEGIN
    historico = historico||' Reg.Excluido';
  END

  IF(HISTORICO <> '') then
  BEGIN
    execute procedure spi_historico('TBFERRAMENTARIA',OLD.ID,historico);
  END
END;




