当前位置:网站首页>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();
边栏推荐
- C#-Linq源码解析之DefaultIfEmpty
- linux系统维护篇:mysql8.0.13源码下载及安装之“傻瓜式”操作步骤(linux-centos6.8)亲测可用系列
- hydra安装及使用
- 系统吞吐量、TPS(QPS)、用户并发量、性能测试概念和公式
- Mysql-5.6.21-centos6.5 source code installation configuration
- 视频会议时听不到声音该如何处理?
- Spark性能调优之道——解决Spark数据倾斜(Data Skew)的N种姿势
- 同花顺是什么?在线开户安全么?
- STM32 ADC acquisition via DMA (HAL Library)
- Problems and recovery of spark streaming checkpoint
猜你喜欢

jsp学习之(一)---------jsp概述
Database mysql master-slave scheme

Special research on Intelligent upgrading of heavy trucks in China in 2022

High availability ResourceManager

每秒处理10万高并发订单的乐视集团支付系统架构分享

Figure operation flow of HAMA BSP Model

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

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

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

视频会议时听不到声音该如何处理?
随机推荐
Blazor University (31)表单 —— 验证
Mysql-5.6.21-centos6.5 source code installation configuration
Linux system maintenance: mysql8.0.13 source code download and installation "fool" operation steps (Linux centos6.8) test available series
MYSQL_ERRNO : 1292 Truncated incorrect date value At add_num :1
[C language] deeply analyze the storage of integer and floating-point types in memory
Learning about ABAP program tuning (IV) loop where key
High availability ResourceManager
[MYSQL]一台windows电脑安装多个mysql-不同版本
redis.clients.jedis.exceptions.JedisDataException ERR invalid password.
vs2017 在调试状态不显示QString值的解决方法
Iterators and generators
Uniapp wechat applet obtains page QR code (with parameters)
Web technology sharing | [Gaode map] to realize customized track playback
【微信小程序封装底部弹出框】一
mysql账号增删改、数据导入导出命令举例
C#-Linq源码解析之DefaultIfEmpty
Call CMD process communication
Spark's NaiveBayes Chinese text classification
联合主键引发的思考
spark-shuffle的读数据源码分析