使用IF Logic调用存储过程中的存储过程吗?
要在存储过程中调用存储过程,语法如下:
If yourInputValue > 100 thencall yourProcedureName1();
else
call yourProcedureName2();
end If ;
END
让我们实现以上语法。为了实现上述概念,让我们创建一个存储过程-
mysql> delimiter //mysql> create procedure Hello_Stored_Procedure()
-> BEGIN
-> select 'Hello World!!!';
-> END
-> //
创建第二个存储过程的查询如下-
mysql> create procedure Hi_Stored_Procedure()-> BEGIN
-> select 'Hi!!!';
-> END
-> //
这是使用IF逻辑在存储过程中调用存储过程的查询-
mysql> DELIMITER //mysql> create procedure test(IN input int)
-> BEGIN
-> If input > 100 then
-> call Hello_Stored_Procedure();
-> else
-> call Hi_Stored_Procedure();
-> end If ;
-> END
-> //
现在您可以在call的帮助下调用存储过程-
mysql> delimiter ;mysql> call test(110);
这将产生以下输出-
+----------------+| Hello World!!! |
+----------------+
| Hello World!!! |
+----------------+
1 row in set (0.00 sec)
以上是 使用IF Logic调用存储过程中的存储过程吗? 的全部内容, 来源链接: utcz.com/z/321919.html