what are stored procedures

what are stored procedures

1 year ago 87
Nature

Stored procedures are a type of subroutine that can be accessed by applications that interact with a relational database management system (RDBMS) . They are groups of SQL statements that are stored together in a database and can be reused over and over again. Stored procedures can perform one or multiple DML operations on a database, and they can accept input parameters and return multiple values of output parameters.

Stored procedures are stored in the database data dictionary and can be used for data validation or access control mechanisms. They can also consolidate and centralize logic that was originally implemented in applications, saving time and memory. Extensive or complex processing that requires execution of several SQL statements can be saved into stored procedures, and all applications can call the procedures.

Stored procedures can receive variables, return results or modify variables and return them, depending on how and where the variable is declared. They can be used to control transaction management in some systems, and they can be invoked from a database trigger or a condition handler.

Benefits of using stored procedures include reusability, easy modification, security, low network traffic, and increased performance. Stored procedures are modular, making it easier to troubleshoot when a problem arises in an application, and they are tunable, which eliminates the need to modify the GUI source code to improve its performance. Stored procedures are also easier to code than building a query through a GUI.

To create a stored procedure in SQL, the syntax is:

CREATE or REPLACE PROCEDURE name(parameters) AS variables; 
BEGIN; 
//statements; 
END;

. To execute a stored procedure, the syntax is:

EXEC procedure_name;

.

Read Entire Article