0

我在sqlfiddle上为 MySql 模式创建了以下存储过程

create procedure foobar(out msg int)
begin
set msg = 100;
end//

当我运行查询以访问 out 参数时

call foobar(@outval);
SELECT @outval;

我收到以下错误

结果集来自 UPDATE。没有数据。

我不确定我做错了什么。请建议。

我将此作为参考MySQL 创建带分隔符的存储过程语法

Sql 小提琴链接:http ://sqlfiddle.com/#!9/a2182/6

4

1 回答 1

3

delimiter在一开始就错过了,所以它应该是

delimiter //
create procedure foobar(out msg int)
begin
 set msg = 100;
end;//

delimiter ;

这是mysql cli中的一个测试用例

mysql> delimiter //
mysql> create procedure foobar(out msg int)
    -> begin
    ->  set msg = 100;
    -> end;//
Query OK, 0 rows affected (0.05 sec)
mysql> delimiter ;
mysql> call foobar(@outval);
Query OK, 0 rows affected (0.01 sec)

mysql> SELECT @outval;
+---------+
| @outval |
+---------+
|     100 |
+---------+
1 row in set (0.01 sec)
于 2015-03-13T10:30:17.033 回答