His great piety invested his prayer with such efficacy that he could bring things in heaven down to earth. It is natural that so godly a king should have used the first respite granted by his wars to carry out his design of erecting a house of worship to God. But in the very night in which David conceived the plan of building the Temple, God said to Nathan the prophet: "Hasten to David. I know him to be a man with whom execution follows fast upon the heels of thought, and I should not like him to hire laborers for the Temple work, and then, disappointed, complain of me. I furthermore know him to be a man who obligates himself by vows to do good deeds, and I desire to spare him the embarrassment of having to apply to the Sanhedrin for absolution from his vow."
David's Prayers Could Bring Heaven Down to Earth
Legends of the Jews 4:50