MySQL存储过程相互调用并获得错误码示例
程序员文章站
2024-02-28 22:44:46
复制代码 代码如下: mysql> mysql> delimiter $$ mysql> mysql> create procedure mypro...
复制代码 代码如下:
mysql>
mysql> delimiter $$
mysql>
mysql> create procedure myproc()
-> modifies sql data
-> begin
-> declare l_status varchar(20);
->
-> call myproc1(l_status);
-> if l_status='duplicate entry' then
-> select concat('warning: using existing definition for location ') as warning;
-> end if;
-> end$$
query ok, 0 rows affected (0.00 sec)
mysql>
mysql> create procedure myproc1(out out_status varchar(30))
-> begin
-> set out_status = 'duplicate entry';
-> end$$
query ok, 0 rows affected (0.00 sec)
mysql>
mysql>
mysql> delimiter ;
mysql> call myproc();
+--------------------------------------------------+
| warning |
+--------------------------------------------------+
| warning: using existing definition for location |
+--------------------------------------------------+
1 row in set (0.00 sec)
query ok, 0 rows affected (0.01 sec)
mysql> drop procedure myproc;
query ok, 0 rows affected (0.00 sec)
mysql> drop procedure myproc1;
query ok, 0 rows affected (0.00 sec)
mysql>
mysql>
上一篇: PHP实现对二维数组某个键排序的方法
下一篇: 注意!PHP 7中不要做的10件事