Stored Procedures

Procedures or algorithms which are made part of a RelationalDatabase schema, typically implemented in a database language (such as SQL or some flavor thereof), and executed as the result of some transaction -- either explicitly, or as the result of a DatabaseTrigger?. They are often used to implement database state change mechanisms that cannot be represented as a single declarative insert, update or delete, or cannot easily be represented as a simple combination of these. For example, in a database designed to support an employee scheduling system, a stored procedure might be used to implement the main "schedule" algorithm that assigns employees to time slots.

Unlike client code, stored procedures run "inside" the database; this has both advantages and disadvantages.


Pros:


Cons:


Some say that StoredProceduresAreEvil.

Discussion regarding the evilness of StoredProcedures moved to StoredProceduresAreEvil.


See Also: DatabaseBestPractices, BusinessLogicInStoredProcedures, PersistentStoredModules, http://www.onjava.com/pub/a/onjava/2003/10/01/middletier.html


EditText of this page (last edited June 11, 2009) or FindPage with title or text search