如何在MySQL存储过程中正确实现END IF语句?
以下是MySQL中END IF语句的语法
IF yourCondition THENyourStatement
ELSE
yourStatement
END IF
这是创建存储过程时END IF语句的演示
mysql> DELIMITER //mysql> CREATE PROCEDURE Sp_Test( IN value INT )
- > BEGIN
- > IF value < 10 THEN
- > select 'Your value is less than 10';
- > ELSE
- > select 'Your value is greater than 10';
- > END IF;
- >
- > END //
mysql> DELIMITER ;
借助CALL命令调用存储过程。
语法如下
CALL yourStoredProcedureName();
现在您可以调用上述存储过程,如下所示
mysql> CALL Sp_Test(15);
以下是输出
+-------------------------------+| Your value is greater than 10 |
+-------------------------------+
| Your value is greater than 10 |
+-------------------------------+
1 row in set (0.00 sec)
以上是 如何在MySQL存储过程中正确实现END IF语句? 的全部内容, 来源链接: utcz.com/z/316269.html