使用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 教师闺蜜祝福语简短