CREATE OR ALTER trigger ttbcolaborador_credito_biud998 for tbcolaborador_credito
active before insert or update or delete position 998
AS
BEGIN
  IF(INSERTING) THEN
    BEGIN
        EXECUTE PROCEDURE SPI_INTEGRACAO('TBCOLABORADOR_CREDITO', NEW.ID, 2);
    END ELSE IF(DELETING) THEN
    BEGIN
        EXECUTE PROCEDURE SPI_INTEGRACAO('TBCOLABORADOR_CREDITO', OLD.ID, 2);
    END ELSE
    BEGIN
        IF( OLD.COLABORADOR_ID <> NEW.COLABORADOR_ID OR
            OLD.VALOR_CREDITO <> NEW.VALOR_CREDITO) THEN
        BEGIN
             EXECUTE PROCEDURE SPI_INTEGRACAO('TBCOLABORADOR_CREDITO', OLD.ID, 2);
        END
    END
END;