A Testosterone blocker will help somewhat. Other medications that cause impotence are psychiatric and blood pressure drugs.
If you have normal penis function, then nothing short of surgery will stop the erections. Many men who have had prostate issues, became impotent after prostate surgery. However, getting prostate surgery without an enlarged prostate is next to impossible.