SO getting an erection isnt a problem, but actually having sex is. He doesnt need a PDE5 inhibitor like viagra then, and he needs something to make him want to use it. Rather than drugs, maybe doing some fantasy stuff, or whatever turns you both on, might help.
If you he needs drugs, I would first get a blood test to see his testosterone and free testosterone levels, and if they are low, the doc would use a low dose of some teststerone product. If that doesnt help, there are other methods, but that is the easiest one to diagnose and treat.