The gemoro says that if one needs to enter a bais knesses to call someone he should learn a avort, a Mishna, a posuk, or ask a child depending who he is and basically this is brought down lehalacha,,,, But since we are talking about a bais knesses why doesn't the gemoro say, he should say a tefillo ketzoro?
Moshe Deutsch(B'shem Dr. Hillel Flamer)
Kew Gardens Hills NY
Sholom Rav,
We are talking here about someone who, presumably, has already Davened, since he is not entering the Shul in order to Daven. So telling him to say a Tefilah out of the blue is not really relevant. A Devar Torah, on the other hand, is always relevant.
In any event, the fact that it mentions a Shul is because of the Isur of entering it for any mundane purpose, so there is no reason to Daven any more than to learn Torah.
Be'Virchas Kol Tuv,
Eliezer Chrysler