Impotence is one of the most challenging side effects of cancer that men have to face. Impotence often involves the inability to get or maintain an erection or to ejaculate.
Surgery for cancer treatment can affect erections by removing or injuring surrounding nerves which are responsible for erections. However, even if nerves are spared during surgery, the healing process for most men can take up to 2 years. It is not entirely known why some men regain full erections while others do not.
Causes of impotence can be physical, psychological, or both. Physical causes include tumours affecting the sexual organs, surgery to remove these tumours, damage to the nerves or blood vessels, hormonal changes, radiation to the pelvis, fatigue, and pain. Emotional ups and downs can also have an impact, including changes in self-image, mood disorders, fear about sexual performance, fear of pain, and feelings of embarrassment. 
There are different techniques that may help reduce the physical symptoms:
- Physiotherapy might help with relieving pain by stretching pelvic floor muscles.
- Medications can be prescribed to increase blood flow to the penis to prevent erectile dysfunction.
- In cases where medications cannot be taken, devices and prosthetics can be implanted to help with erectile dysfunction.
Studies suggest that different methods to promote erections starting within weeks or months after surgery can help some men recover sexual function. You may hear this called penile rehabilitation, or erectile rehabilitation. 
It is important to talk to your doctor or a counselor about any sexual issues you may be experiencing, though both patient and health professional may be reluctant to bring it up. This is an issue that can have a long-term impact on quality of life.