Certainly stress can affect the sex interest and erection. The fact that you are able to obtain erections in selected cases suggests that it is unlikely to be a physical problem.
You stated that Levitra was tried. There are some cases where Viagra works better than Levitra and vice versa - you may want to explore that option.
Another option would be to examine whether your testosterone levels are normal. This can be determined via a simple blood total testosterone level.
If everything is negative, you may want to consider whether stress counselling may be a helpful option in addressing your symptoms.
Followup with your personal physician is essential.
This answer is not intended as and does not substitute for medical advice - the information presented is for patient education only. Please see your personal physician for further evaluation of your individual case.
Thanks,
Kevin, M.D.