使用IF Logic调用存储过程中的存储过程吗?
要在存储过程中调用存储过程,语法如下:
If yourInputValue > 100 then
call 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)
热门推荐
10 中秋祝福语给父亲简短
11 小红书生日祝福语简短
12 出海霸气祝福语大全简短
13 布置会场生日祝福语简短
14 幽默小姐姐祝福语简短
15 小清新的祝福语简短
16 七一祝福语明信片文案简短
17 姥爷生日祝福语简短精辟
18 老婆生日祝福语简短孩子