CREATE trigger ttbperfil_b02i for tbperfil
active before insert position 0
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('TBPERFIL', NEW.ID, HISTORICO);
  END
end;

CREATE trigger ttbperfil_b0d2 for tbperfil
active before delete position 0
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('TBPERFIL', OLD.ID, HISTORICO);
  END
end;