当前位置:网站首页>MySQL stored procedure exception handling error code: 1337
MySQL stored procedure exception handling error code: 1337
2022-06-22 17:03:00 【Seven days at night】
Baidu is saying , To declare variables first , Restart cursor . The cursor (cursor) Must be declared before declaring the handler , And variables and conditions must be declared before declaring cursors or handlers .Error code : 1337
Variable or condition declaration after cursor or handler declaration
The wrong way to write :
DROP PROCEDURE IF EXISTS `proc_statistical` ;
DELIMITER ;;
CREATE DEFINER = `root` @`localhost` PROCEDURE `proc_statistical` ()
BEGIN
#Routine body goes here...
-- Traversal data end flag
DECLARE t_error INTEGER DEFAULT 0;
-- Bind the end flag to the cursor
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION,SQLWARNING,NOT FOUND SET @t_error = 1;
DECLARE cnt INT ;
START TRANSACTION ;
Content
IF @t_error = 1 THEN
ROLLBACK;
// Log failure
ELSE
// Log success
COMMIT;
END IF;
END ;;
DELIMITER ;
CALL proc_statistical();
Error message reporting error :
Will prompt in DECLARE t_error INTEGER DEFAULT 0; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION,SQLWARNING,NOT FOUND S Error on the right .
Error code : 1337
Variable or condition declaration after cursor or handler declaration
After a careful search of the information, I found that : If you define the cursor before other variables , There will be errors 1337.
Correct writing :
DROP PROCEDURE IF EXISTS `proc_statistical` ;
DELIMITER ;;
CREATE DEFINER = `root` @`localhost` PROCEDURE `proc_statistical` ()
BEGIN
#Routine body goes here...
DECLARE cnt INT ;
-- Traversal data end flag
DECLARE t_error INTEGER DEFAULT 0;
-- Bind the end flag to the cursor
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION,SQLWARNING,NOT FOUND SET @t_error = 1;
START TRANSACTION ;
Content
IF @t_error = 1 THEN
ROLLBACK;
// Log failure
ELSE
// Log success
COMMIT;
END IF;
END ;;
DELIMITER ;
CALL proc_statistical();
边栏推荐
- [pop up box at the bottom of wechat applet package] I
- 高可用性的ResourceManager
- Test for API
- 使用 POST 向 ASP.NET Core 传递数据时的长度限制与解决方案
- 基于.NetCore开发博客项目 StarBlog - (12) Razor页面动态编译
- jsp學習之(二)---------jsp脚本元素和指令
- Spark性能调优之道——解决Spark数据倾斜(Data Skew)的N种姿势
- 招行23型号UKey在win7上无法识别
- Short video source code development, high-quality short video source code need to do what?
- 华为云招募工业智能领域合作伙伴,强力扶持+商业变现
猜你喜欢
![[Alibaba cloud server - install MySQL version 5.6 and reinstall]](/img/5a/50b1de5f58235f6d11f6ad1eecc455.png)
[Alibaba cloud server - install MySQL version 5.6 and reinstall]

WPF效果第一百九十篇之再耍ListBox

web技术分享| 【高德地图】实现自定义的轨迹回放

【进阶自动化测试第一步】1分钟带你了解自动化测试

JSP learning (2) -- JSP script elements and instructions

图计算Hama-BSP模型的运行流程
![Web technology sharing | [Gaode map] to realize customized track playback](/img/0b/25fc8967f5cc2cea626e0b3f2b7594.png)
Web technology sharing | [Gaode map] to realize customized track playback

ABP Framework 5.3.0 版本新增功能和变更说明

系统吞吐量、TPS(QPS)、用户并发量、性能测试概念和公式

jsp学习之(三)--------- jsp隐式对象
随机推荐
scala-for推导:能够在for表达式中的最初部分定义值,并在(外面)后面的表达式中使用该值
mysql 字符串字段转浮点型字段
jsp学习之开发环境的配置
Interview knowledge points
web技术分享| 【高德地图】实现自定义的轨迹回放
The world's "first" IEEE privacy computing "connectivity" international standard led by insight technology was officially launched
ERROR 1364 (HY000): Field ssl_cipher doesnt have a default value
How to open an account in flush? Is it safe to open an account online?
Spark on data skew
Redis implements the correct posture of the delay queue
mysql5.7.27安装之windows8.1 64
使用IDM让百度云加速的方法
【游标的嵌套】mysql存储过程游标的嵌套
scala的相等性
调用cmd 进程通信
spark-shuffle的读数据源码分析
【微信小程序封装底部弹出框】一
.NetCore实现图片缩放与裁剪 - 基于ImageSharp
spark的NaiveBayes中文文本分类
spark常用 算子小总结