These people who are claiming you should go with 9mm instead of .40S&W because of the risk of "shooting through walls," are mistaken, IMO.
The risk of over-penetration with 9mm is significantly HIGHER than with .40 or any of the larger-caliber rounds. Especially if you use ball ammo (not a hollowpoint or softpoint).
The 9mm is an extremely high-velocity round, and there are many documented cases of over-penetration with it. Also, there are a number of rather bizarre horror stories of junkies being hit multiple times with 9mm ball rounds and not stopping.
If you have a 9mm, I wouldn't say that you should take it back or anything, because modern ammunition has greatly made up for the weaknesses of the cartridge. Get some Hydra-Shoks or CorBons for carrying to prevent over-penetration, and learn a double-tap shooting technique.
However if you are in the market, I would strongly steer you towards a .40S&W. It is actually a 10mm bullet (some people call it the "10mm short") and has a greater cross-sectional area and somewhat lower velocity than the 9mm. Historically the .40 evolved out of the 10mm Norma cartridge, which was designed for FBI use but was deemed too powerful and hard to control.
My favorite thing about the .40, though, is that most practice ammo for it has flat-nosed bullets, which more closely simulate hollowpoint ballistics. Plus, they make a neater hole in the paper.

For carry, I would still spend the extra money for CorBons.
Oh -- and take a defensive shooting class. Even if you don't plan on getting a CCW permit soon, or don't need to take a class to get one where you live, I promise you'll learn something useful.