CALL
Example
Section titled “Example”CALL procedure_name();Output
Section titled “Output”Query OK, 0 rows affected (0.00 sec)Explanation
Section titled “Explanation”The CALL command is used to execute a stored procedure in MySQL that has been defined previously. In this syntax, procedure_name() is the name of the stored procedure to be executed. The result of the CALL command indicates whether the procedure was executed successfully without any error. The message Query OK, 0 rows affected denotes that the stored procedure was executed successfully.
Example
Section titled “Example”CREATE PROCEDURE GetEmployee @ID INT ASBEGIN SELECT * FROM Employees WHERE EmployeeId = @IDEND;GO
CALL GetEmployee 1;Output
Section titled “Output”| EmployeeId | Name | JobTitle ||------------|--------|----------|| 1 | John | Manager |Explanation
Section titled “Explanation”In the above code, a stored procedure named “GetEmployee” is created that takes one parameter and queries the “Employees” table for the row where the “EmployeeId” matches the input parameter. The “CALL” statement is then used to execute this stored procedure, providing “1” as the parameter. The output is as shown in the ‘Output’ section.