OUT or INOUT parameter not working

耗尽温柔 提交于 2019-12-06 15:21:20

it works for me

mysql> CREATE DEFINER=`root`@`localhost` PROCEDURE `testing_inout`(`a` int,INOUT `b` int)
    -> BEGIN
    -> 
    -> END
    -> ;
Query OK, 0 rows affected (0.00 sec)

The second parameter because it's inout it need to be a variable:

mysql> set @c:=1;
Query OK, 0 rows affected (0.00 sec)

mysql> call testing_inout(1,@c);
Query OK, 0 rows affected (0.00 sec)

if you try this it will return 1:

delimiter |
CREATE DEFINER=`root`@`localhost` PROCEDURE `testing_inout`(`a` int,INOUT `b` int)
BEGIN
select b;
END
|
delimiter ;

mysql> call testing_inout(1,@c);
+------+
| b    |
+------+
|    1 |
+------+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.00 sec)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!