What are the advantages of stored procedure?
Atomicity : SQL commands in a stored procedure are within transaction scope, which means that either all of the SQL statements in a stored procedure will execute, or none will. This is known as atomicity.
Speed : Unlike standard SQL statements, stored procedures are compiled and optimized by the database server. This optimization involves using information about the structure of a particular database that’s required at execution time by the stored procedure. This process of storing execution information (the execution plan) is a time saver, especially if the stored procedure is called many times.
Flow Control : A stored procedure can take advantage of control flow statements such as IF…ELSE, and FOR and WHILE loops, that are not typically available within a basic SELECT statement.
Security : Stored procedures can also act as an additional security layer. For example, we could allow access to a stored procedure that generates an average salary for a company, while never allowing its users to see the salary information directly.
Reduced Network Traffic : A properly designed application that processes large amounts of data using stored procedures returns only the data that is needed by the client. This reduces the amount of data transmitted across the network.
Modularization :Modularization is the process of writing reusable code units.