- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to quit/ exit from MySQL stored procedure?
We can quit/ exit from MySQL stored procedure with the help of the LEAVE command.
The following is the syntax.
Leave yourLabelName;
The following is an example. Here, we are creating a new procedure.
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)
Above, we have set the following LEAVE command to exit from the procedure. If Var1 is “NULL”, the procedure will exit.
LEAVE proc_Exit;
To change the delimiter to ‘;’.
mysql>delimiter ; mysql>
To call stored procedure, we need to use CALL command followed by the procedure name.
The following is the syntax.
call yourStoredProcedureName;
Advertisements