What Dave already said:
"More importantly, would they lose their energy so quickly that the pilot who fired them would have to fly through them? I just don't think a 9mm round would have enough power to even consider using in an aircraft.
I'm sure someone will come along soon and give you a nice muzzle velocity/energy comparison between a 9mm pistol round and a US .50 Caliber round. There is a huge difference in mass and power."
9mm Para W:9.5grams, MV:368m/s, E:643J
.303 W:12grams, MV:783m/s, E:3574J
.50BMG W: 52grams, MV: 883m/s, E:20,195J
Considering the added speed of the aircraft of, say, 300mph/480kmh/133m/s, the aerodynamic shape and how rapidly the bullet would lose speed after leaving the muzzle Dave's idea of running into your own bullets is not too far fetched at all. While you could punch a hole in aircraft skin from very close range the bullet simply would no have enough energy to do serious harm. As a defensive weapon it could do something since the attacking aircraft would "collide" with the bullet but even then the effect would be no more than a punctured radiator or a cut ignition cable etc.
In fact sometimes the observers in light bombers were armed with submachineguns, but that only had a function of a moral boost, at best.
-C+