Home > Database > Mysql Tutorial > body text

How to exit a MySQL stored procedure?

WBOY
Release: 2023-09-13 23:33:11
forward
1686 people have browsed it

How to exit a MySQL stored procedure?

We can use the LEAVE command to exit the MySQL stored procedure.

The following is the syntax.

Leave yourLabelName;
Copy after login

Below is an example. Here we are creating a new process.

mysql> delimiter //
mysql> CREATE PROCEDURE ExitQuitDemo2(IN Var1 VARCHAR(20))
   -> proc_Exit:BEGIN
   -> IF Var1 IS NULL THEN
   -> LEAVE proc_Exit;
   -> END IF;
   -> END //
Query OK, 0 rows affected (0.16 sec)
Copy after login

Above, we set the following LEAVE command to exit the program. If Var1 is "NULL", the program will exit.

LEAVE proc_Exit;
Copy after login

Change the delimiter to ";".

mysql>delimiter ;
mysql>
Copy after login

To call a stored procedure, we need to use the CALL command, followed by the procedure name.

The following is the syntax.

call yourStoredProcedureName;
Copy after login

The above is the detailed content of How to exit a MySQL stored procedure?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!