The statement to execute stored procedures in mysql is "CALL". The CALL statement can call the specified stored procedure. After calling the stored procedure, the database system will execute the SQL statement in the stored procedure and then return the result to the output value; the syntax is "CALL name of the stored procedure ([parameters [...]])" ;". In mysql, using the CALL statement to call and execute stored procedures requires EXECUTE permission to take effect.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
The statement to execute the stored procedure in mysql is "CALL
".
MySQL CALL statement
The CALL statement is used in MySQL to call stored procedures. When a stored procedure is called, the database system executes the SQL statements in the stored procedure and returns the results as output values.
Calling and executing stored procedures requires EXECUTE permission (information about EXECUTE permission is stored in the USER_PRIVILEGES table under the information_schema database).
The CALL statement receives the name of the stored procedure and any parameters that need to be passed to it. The basic syntax is as follows:
CALL sp_name([parameter[...]]);
Among them, sp_name represents the name of the stored procedure, and parameter represents the stored procedure. parameters.
MySQL CALL statement calls and executes the stored procedure example
Create a stored procedure named ShowStuScore. The function of the stored procedure is to query the student's score from the student score information table. Score information
DELIMITER // CREATE PROCEDURE ShowStuScore() BEGIN SELECT * FROM tb_students_score; END //
Call and execute the stored procedure ShowStuScore()
CALL ShowStuScore();
Explanation: Because the stored procedure In fact, it is also a function, so the () symbol is required after the stored procedure name, even if no parameters are passed.
[Related recommendations: mysql video tutorial]
The above is the detailed content of What is the statement to execute stored procedure in mysql. For more information, please follow other related articles on the PHP Chinese website!