为了账号安全,请及时绑定邮箱和手机立即绑定

创建带有多个OUT类型参数的存储过程-报错1172 - Result consisted of more than one row

mysql> CREATE PROCEDURE RmUserByAge_Infos(IN p_age SMALLINT UNSIGNED,OUT deleteUsers SMALLINT UNSIGNED,OUT userCounts SMALLINT UNSIGNED)

    -> BEGIN

    -> DELETE FROM users WHERE age = p_age;

    -> SELECT ROW_COUNT() FROM users INTO deleteUsers;

    -> SELECT COUNT(id) FROM users INTO userCounts;

    -> END

    -> //

Query OK, 0 rows affected

mysql> CALL RmUserByAge_Infos(23,@user,@num);

1172 - Result consisted of more than one row

mysql> SELECT @user;

+-------+

| @user |

+-------+

| NULL  |

+-------+

1 row in set


mysql> SELECT @num

;

+------+

| @num |

+------+

| NULL |

+------+

1 row in set

数据已经被删除,但参数不能正确的返回,请教一下,这是怎么回事呢?要如何解决呢?

正在回答

1 回答

把SELECT ROW_COUNT() FROM users INTO deleteUsers;这一行中的FROM users去掉;

select from row_count from users; 返回的是好几行记录

select from row_count(); 返回的才是一行记录


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
与MySQL的零距离接触
  • 参与学习       396886    人
  • 解答问题       3353    个

本课程涵盖全部MySQL数据库的基础,学习MySQL数据库的基础知识

进入课程

创建带有多个OUT类型参数的存储过程-报错1172 - Result consisted of more than one row

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信