码迷,mamicode.com
首页 > 其他好文 > 详细

在过程中执行truncate table总是报语法错误

时间:2021-05-25 18:31:26      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:set   weight   pre   改变   tin   handle   handler   image   continue   

源代码如下:

BEGIN

DECLARE i INT;
DECLARE time_1 datetime;
DECLARE ID_1 int;
DECLARE charge_1 FLOAT;
DECLARE length_1 FLOAT;
DECLARE err_1 FLOAT;
DECLARE RSSI_1 FLOAT;
DECLARE stopflag INT DEFAULT 0;

TRUNCATE TABLE 220_1_copy;
DECLARE mycursor CURSOR FOR SELECT time,ID,charge,length,err,RSSI FROM 220_1 WHERE index_1 <100; DECLARE CONTINUE HANDLER FOR NOT FOUND SET stopflag=1; OPEN mycursor; REPEAT FETCH mycursor INTO time_1,ID_1,charge_1,length_1,err_1,RSSI_1; INSERT INTO 220_1_copy SET time=time_1,ID=ID_1,charge=charge_1,length=length_1,err=err_1,RSSI=RSSI_1; UNTIL stopflag=1 END REPEAT; CLOSE mycursor; END

保存代码提示:技术图片

改变红色代码 truncate table的位置就没事了如下:

BEGIN
    #Routine body goes here..
DECLARE i INT;
DECLARE time_1 datetime;
DECLARE ID_1 int;
DECLARE charge_1 FLOAT;
DECLARE length_1 FLOAT;
DECLARE err_1 FLOAT;
DECLARE RSSI_1 FLOAT;
DECLARE stopflag INT DEFAULT 0;


DECLARE mycursor CURSOR FOR SELECT time,ID,charge,length,err,RSSI FROM 220_1 WHERE index_1 <100;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET stopflag=1;

TRUNCATE TABLE 220_1_copy;

OPEN mycursor;
REPEAT
    FETCH mycursor INTO time_1,ID_1,charge_1,length_1,err_1,RSSI_1;
    INSERT INTO 220_1_copy SET time=time_1,ID=ID_1,charge=charge_1,length=length_1,err=err_1,RSSI=RSSI_1;
    UNTIL stopflag=1 END REPEAT;
CLOSE mycursor;
END

不知道为啥!!!

在过程中执行truncate table总是报语法错误

标签:set   weight   pre   改变   tin   handle   handler   image   continue   

原文地址:https://www.cnblogs.com/flash610/p/14808403.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!