当前位置:网站首页>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();
边栏推荐
- .NET 发布和支持计划介绍
- 每秒處理10萬高並發訂單的樂視集團支付系統架構分享
- spark-shuffle的写入器源码分析
- Figure operation flow of HAMA BSP Model
- 使用 POST 向 ASP.NET Core 传递数据时的长度限制与解决方案
- Scala for derivation: the ability to define a value in the first part of a for expression and use it in subsequent (outer) expressions
- Iterators and generators
- Database mysql master-slave scheme
- Add a millennial sign to a number (amount in millennia)
- redis.clients.jedis.exceptions.JedisDataException ERR invalid password.
猜你喜欢
![[pop up box 2 at the bottom of wechat applet package]](/img/31/266e6a1f4200347c9324ea37b78562.png)
[pop up box 2 at the bottom of wechat applet package]

面对默认导入失败的情况

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

JMeter use case

In case of default import failure

What is restful and what rules should be followed when designing rest APIs?

每秒處理10萬高並發訂單的樂視集團支付系統架構分享

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

IDEA安装总结

What should I do if I can't hear a sound during a video conference?
随机推荐
redis.clients.jedis.exceptions.JedisDataException ERR invalid password.
mysql账号增删改、数据导入导出命令举例
快速掌握 ASP.NET 身份认证框架 Identity - 用户注册
Unable to connect after win10 WiFi is disconnected
WPF 实现星空效果
面对默认导入失败的情况
【阿里云服务器-安装mysql的5.6版本安装,重装】
JSP learning (2) -- JSP script elements and instructions
接口(优化类型注解)
[pop up box 2 at the bottom of wechat applet package]
On the closure function of Scala
[Alibaba cloud server - install MySQL version 5.6 and reinstall]
Purchase guide - how to purchase a high-quality conference tablet, these aspects must be compared
IDEA安装总结
你管这破玩意儿叫高可用?
Basic application of scala for
Mysql-5.6.21-centos6.5 source code installation configuration
Qt笔记-QMap自定义键(key)
In the era of video explosion, who is supporting the high-speed operation of video ecological network?
Examples of MySQL account addition, deletion, modification, data import and export commands