Mysql - 如何退出/退出存储过程

2021-12-20 00:00:00 sql mysql stored-procedures

我有一个非常简单的问题,但我没有得到任何使用 Mysql 退出 SP 的简单代码.谁能告诉我怎么做?

I have very simple question but i did't get any simple code to exit from SP using Mysql. Can anyone share with me how to do that?

CREATE PROCEDURE SP_Reporting(IN tablename VARCHAR(20))
BEGIN
     IF tablename IS NULL THEN
          #Exit this stored procedure here
     END IF;

     #proceed the code
END;

推荐答案

CREATE PROCEDURE SP_Reporting(IN tablename VARCHAR(20))
proc_label:BEGIN
     IF tablename IS NULL THEN
          LEAVE proc_label;
     END IF;

     #proceed the code
END;

相关文章