SET TERM ^ ;

CREATE trigger ttbmodelo_kit_b09u for tbmodelo_kit
active before update position 9
AS
declare variable HISTORICO VARCHAR(500);
begin
    HISTORICO = '';

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

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

    IF(NEW.TIPO_TALAO IS DISTINCT FROM OLD.TIPO_TALAO) THEN
    BEGIN
        HISTORICO = HISTORICO||'TIPO TALÃO: '||OLD.TIPO_TALAO||' -> '||NEW.TIPO_TALAO;
    END

    IF(HISTORICO <> '') THEN
    begin
        EXECUTE PROCEDURE SPI_HISTORICO('TBMODELO_KIT', NEW.ID, HISTORICO);
    end 
end
^

SET TERM ; ^

