Home >Database >Mysql Tutorial >What is the statement to execute stored procedure in mysql

What is the statement to execute stored procedure in mysql

青灯夜游
青灯夜游Original
2022-06-20 15:57:009018browse

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.

What is the statement to execute stored procedure in mysql

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 //

What is the statement to execute stored procedure in mysql

Call and execute the stored procedure ShowStuScore()

CALL ShowStuScore();

What is the statement to execute stored procedure in mysql

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn