当前位置:网站首页>Result consisted of more than one row
Result consisted of more than one row
2022-08-09 07:56:00 【洛央虲】
呀,开始学习写存储结构了。呼呲呼呲的写了一个删除数据,返回修改的数据数量和剩余的数据数量的存储结构
mysql>CREATE PROCEDURE removeGoodAndReturnInfos(IN b_name VARCHAR(40),OUT delete_goods SMALLINT UNSIGNED,OUT goodCounts SMALLINT UNSIGNED) mysql>BEGIN mysql>DELETE from tdb_goods where brand_name = b_name;
mysql>SELECT ROW_COUNT() from tdb_goods INTO delete_goods;
mysql>SELECT COUNT(good_id) from tdb_goods INTO goodCounts;
mysql>END
完工!来执行一下!
mysql>call removeGoodAndReturnInfos("索尼",@a,@b);
ERROR 1172 (42000): Result consisted of more than one row
欸,怎么出错了。
一看到这个错误,就知道是在使用SELECT INTO的时候出现了多于一行的情况,导致removeGoodAndReturnInfos这个存储过程执行错误
由于我在记录改变行数多写了from tdb_goods,将这块去掉,修改如下:
mysql>delimiter //
mysql>CREATE PROCEDURE removeGoodAndReturnInfos(IN b_name VARCHAR(40),OUT mysql>delete_goods SMALLINT UNSIGNED,OUT goodCounts SMALLINT UNSIGNED) mysql>BEGIN mysql>DELETE from tdb_goods where brand_name = b_name;
mysql>SELECT ROW_COUNT() INTO delete_goods;
mysql>SELECT COUNT(goods_id) from tdb_goods INTO goodCounts;
mysql>END
mysql>//
我去~,咋又出下你问题!
mysql>call procedure removeGoodAndReturnInfos("宏基",@a,@b);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'procedure removeGoodAndReturnInfos("宏基",@a,@b)' at line 1
额,多写了procedure,把这个去掉,再试试。
mysql> call removeGoodAndReturnInfos("IBM",@a,@b);
Query OK, 0 rows affected (0.00 sec)
哈哈哈,成功了!看看变量值。
mysql> select @a,@b; +------+------+
| @a | @b | +------+------+
| 2 | 9 | +------+------+
1 row in set (0.00 sec)
这个问题提醒我们,编写的时候一定要注意注意再注意。多留点神。
附上学习存储过程的思维导图
边栏推荐
猜你喜欢
SOLIDWORKS Simulation教程:计算物体的固有频率
Learning Notes---Machine Learning
Shell编程之正则表达式
CoCube传感器MPU6050笔记
MDK Keil debug时, watch1中全局变量不更新
(四)BP神经网络预测(上)
The String class objects created by the JVM memory allocation and the difference between equals and = =
NAT地址转换的原理与配置
Shell--常用小工具(sort、uniq、tr、cut)
如何把无用的代码注释为 Deprecated 弃用
随机推荐
Difference Constraint - Graph Theory
MYSQLWorkbench看数据库ER图
【机器学习】降维代码练习
静态路由的原理与配置
权限(下)
SSM integration development case
H3C_利用策略路由实现出口双线路负载(选路)的部署
.net(二) 配置数据库
Web 3D渲染引擎HOOPS Communicator动画编辑器的使用 | HOOPS教程
String类创建的对象在JVM中的内存分配和equals与==的区别
CUDA和cuDNN 安装10.0版本
IDEA文件UTF-8格式控制台输出中文乱码
.net(五) 业务层实现
oracle权限问题
贪吃蛇小游戏——C语言
nvm安装以及管理多版本node教程
Win10桌面图标排列混乱
设备指纹详解之识别垃圾账号
Anaconda 更换默认虚拟环境
JS基础1