
要在存储过程中调用存储过程,语法如下 –
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 -> //Query OK, 0 rows affected (0.18 sec)
创建第二个存储过程的查询如下 –
mysql> create procedure Hi_Stored_Procedure() -> BEGIN -> select 'Hi!!!'; -> END -> //Query OK, 0 rows affected (0.17 sec)
这里是使用 IF 逻辑在存储过程中调用存储过程的查询 –
存了个图
视频图片解析/字幕/剪辑,视频高清保存/图片源图提取
17 查看详情
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 -> //Query OK, 0 rows affected (0.18 sec)
现在您可以借助 call 来调用存储过程 –
mysql> delimiter ;mysql> call test(110);
这将产生以下输出 –
+----------------+| Hello World!!! |+----------------+| Hello World!!! |+----------------+1 row in set (0.00 sec)Query OK, 0 rows affected (0.02 sec)
以上就是使用 IF 逻辑在存储过程中调用存储过程?的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/326028.html
微信扫一扫
支付宝扫一扫