We study the gas accretion onto a supermassive black hole (SMBH) using the 3D SPH code GADGET-3 on scales of 0.1-200 pc. First we test our code with spherically symmetric, adiabatic Bondi accretion problem. We find that our simulation can reproduce the expected Bondi accretion flow very well for a limited amount of time until the effect of outer boundary starts to be visible. We also find artificial heating of gas near the inner accretion boundary due to the artificial viscosity of SPH. Second, we implement radiative cooling and heating due to X-rays, and examine the impact of thermal feedback by the central X-ray source. The accretion flow roughly follows the Bondi solution for low central X-ray luminosities, however, the flow starts to exhibit non-spherical fragmentation due to thermal instability for a certain range of central L_X, and a strong overall outflow develops for greater L_X. The cold gas develops filamentary structures that fall into the central SMBH, whereas the hot gas tries to escape through the channels in-between the cold filaments. Such fragmentation of accreting gas can assist in the formation of clouds around AGN, induce star-formation, and contribute to the observed variability of narrow-line regions.