
The MySQL Workshop
By :

Stored procedures are the workhorses of your MySQL database. Similar to UDFs, they can run multiple SQL statements, contain the logic flow, and return the results. Stored procedures are used for situations where you want to store queries that will need to be run multiple times. For example, if a set of queries need to be run daily, they can be created as stored procedures. Where UDFs return a single result, stored procedures can return a single result, or they can return entire record sets. They are ideal for moving extensive processing tasks to a MySQL server. Imagine that you are working in a sales application that's connected to a MySQL database and you need to record a sale. Your application would record a sale by doing the following: