Is it a good practice to have nested stored procedures (meaning calling a stored procedure inside another stored procedure)? Are there any precautions that one should follow while nesting stored procedures? Is there a permissible limit on how many one can nest inside?
Thanks in anticipation
Yes, there is a limitation on the level of nesting. From the manual:
The fact that the limitation exists might imply that nesting stored procedure calls too much isn’t a very good thing. Yet the maximum level seems to me big enough for one not to worry about nesting calls like 5 or so levels deep.
And indeed, I’ve never heard that having nested calls in your design introduced drawbacks of any kind, nor have I experienced any actual disadvantage from calling stored procedures from one another. On the contrary, I think, factoring your server-side code enables you to make your design more flexible. Or, if nothing else, it at least allows you to make your stored procedures’ code more manageable by splitting the larger ones into more moderate-sized (and possibly logically complete) units.
I do not mean to say that you should always try to factor your stored procedures at any cost, I just wouldn’t see anything wrong with your having to nest your procedures if that would fit your design better.