使用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 好听的元旦简短祝福语