#Error1064 sql语法DECCLARE和CURSOR FOR SELECT

时间:2018-09-28 08:20:00

标签: mysql stored-procedures mysql-error-1064

我一直收到此错误: “错误1064:您的SQL语法有错误;请查看与您的MySQL服务器版本相对应的手册,以获取在'(ORDER BY processdate DESC)rwn,s.serno附近使用正确的语法。            FROM ord_success在第5行的ga'“

CREATE  PROCEDURE move_sucess_order(p_gwserno DOUBLE, p_mindate DOUBLE, p_keepsize DOUBLE)
BEGIN
DECLARE NOT_FOUND INT DEFAULT 0;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET NOT_FOUND = 1;
   DECLARE rec CURSOR FOR SELECT serno FROM ( SELECT row_number() OVER(ORDER BY processdate DESC) rwn,  s.serno
       FROM ord_success s WHERE gatewayserno = p_gwserno AND processdate < p_mindate
       ) t WHERE rwn > p_keepsize; OPEN rec;
 FETCH rec INTO;
 WHILE NOT_FOUND=0
 DO
 INSERT INTO ord_success_arc
    SELECT serno, gatewayserno, targetserno, meterpointserno, mastermessagetype,
         messagetype, rawcontent, createdate, createuser, createtransactionid, requesttype, processtype,
         lastexecutorendpoint, orderstatus, bidirectedserno, externalherefno, processtarget, isasync, processdate,
         lpstartdate, lpenddate, updatedate, updateuser, updatetransactionid, recordstatus, externalsdmsource, externalsdmserno
     FROM ord_success WHERE serno = rec.serno;
     DELETE FROM ord_success WHERE serno = rec.serno;

    FETCH  INTO;
    END WHILE;
    CLOSE ;

我是mysql的新手。我深入检查了mysql手册。但是我不知道如何解决这个问题。感谢您的帮助。

0 个答案:

没有答案