Tag Archives: stored procedures

What are stored procedures?

30 Jul

Stored procedures

These are used when a developer is using the N-Tier architecture.

Stored procedures are scripts that call set pieces of information from the database.  They help to make development easier because it means that that bit of code can be called upon again and again instead of writing new code every time that particular bit of information is required.

I found a baking analogy quite useful when learning about stored procedures. So if you imagine that creating a web page is like making a tart, (stay with me here…), the stored procedures are like little recipes for all of the separate parts and using all of them together makes the whole dish. So, there would be a stored proc for the pastry, one for the filling and one for the sauce to pour over the top. Then if someone else needed the pastry one, they can just call that instead of writing that bit of code again. But they would need a different stored procedure if a different filling was required.

Stored procedures are called by services which sit in the Services Layer above. The overview below indicates the order of the data flow.