当前位置:网站首页>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)这个问题提醒我们,编写的时候一定要注意注意再注意。多留点神。
附上学习存储过程的思维导图 
边栏推荐
猜你喜欢

C#基础学习

String类创建的对象在JVM中的内存分配和equals与==的区别

MDK Keil debug时, watch1中全局变量不更新

SiamFC:用于目标跟踪的全卷积孪生网络 fully-convolutional siamese networks for object tracking

Solidworks 2022 Inspection新增功能:光学字符识别、可自定义的检查报告

HOOPS助力 SolidWorks edrawings 引入AR/VR技术

C语言:汽水瓶详解

练习电影卡片、过渡、动画、变形、旋转,练习时钟、立方体、缩放

【机器学习】随机森林、GBDT、XGBoost、LightGBM等集成学习代码练习

.net(四) 数据层实现
随机推荐
Anaconda replaces the default virtual environment
.net(二) 配置数据库
C语言:调整奇数偶数顺序
3.MySQL插入数据, 读取数据、Where子句和Order By关键字
Selenium测试案例一步步学之(2)Selenium自动测试脚本模块化(下)
Classes and Structures
如何把无用的代码注释为 Deprecated 弃用
【机器学习】随机森林、GBDT、XGBoost、LightGBM等集成学习代码练习
记录一次客户的APP数据库版本号升级失败的情况
链表专项练习(三)
Oracle 限制时将空值排除
数据库索引原理
Shell编程之正则表达式
VLAN与静态VLAN的配置
Anaconda 更换默认虚拟环境
SA-Siam:用于实时目标跟踪的双重连体网络A Twofold Siamese Network for Real-Time Object Tracking
View log common commands
The String class objects created by the JVM memory allocation and the difference between equals and = =
Codeforces Round #359 (Div. 2) C. Robbers' watch Violent Enumeration
A brief introduction to microservice architecture