Table of Contents
What is a Stored Procedure?
A stored procedure is a set of SQL statements that form a logical unit to perform a specific task. It encapsulates a group of operations or queries executed on a database server.
Why Use Stored Procedures?
Stored procedures isolate the client from implementation details and the underlying schema. They also reduce network traffic by executing SQL statements in batches, minimizing multiple client requests.
Syntax:
DELIMITER $$ CREATE PROCEDURE `simpleprocedure`(IN name varchar(50), IN user_name varchar(50), IN branch varchar(50)) BEGIN INSERT INTO student (name, user_name, branch) VALUES (name, user_name, branch); END$$ DELIMITER ;
Copy and paste this code into your SQL command line to create the stored procedure.