SET TERM ^ ;

CREATE trigger ttbparametros_insumo_b01u for tbparametros_insumo
active before update position 0
AS
DECLARE VARIABLE HISTORICO VARCHAR(500);
BEGIN
    HISTORICO = '';

    IF(NEW.DESCRICAO IS DISTINCT FROM OLD.DESCRICAO) THEN
    BEGIN
        HISTORICO = 'DESC: '||OLD.DESCRICAO||' -> '||NEW.DESCRICAO;
    END

    IF(HISTORICO <> '') THEN
    BEGIN
        EXECUTE PROCEDURE SPI_HISTORICO('TBPARAMETROS_INSUMO', NEW.ID, HISTORICO);
    END
END
^

SET TERM ; ^

SET TERM ^ ;

CREATE trigger ttbparametros_insumo_b01i for tbparametros_insumo
active before insert position 0
AS
declare variable HISTORICO VARCHAR(500);
begin
    HISTORICO = '';

    IF(NEW.ID IS NOT NULL) THEN
    BEGIN
        HISTORICO = 'REGISTRO INCLUÍDO';
    END

    IF(HISTORICO <> '') THEN
    BEGIN
        EXECUTE PROCEDURE SPI_HISTORICO('TBPARAMETROS_INSUMOS', NEW.ID, HISTORICO);
    END
end
^

SET TERM ; ^

