0

我有一个由另一个游标中的游标组成的过程,但是在导入数据库时​​出现了一些错误。

    create procedure genData()
    BEGIN
    DECLARE PORT,I,LID INT DEFAULT 0;
    DECLARE temp INT DEFAULT 0;
    declare done,done1 BOOL default FALSE;

    DECLARE cur1 cursor for select distinct LinkID from MAIN_TBL;
    DECLARE cur2 cursor for select Port from TEMP_LINK_TOPPORT;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
    open cur1;
    rl: LOOP
            fetch cur1 INTO LID;
            IF done=TRUE THEN
                    LEAVE rl;
            END IF;
            drop table if exists TEMP_LINK_TOPPORT;
            create table if not exists TEMP_LINK_TOPPORT(NoOfBytes INT,Port INT);
            INSERT INTO TEMP_LINK_TOPPORT
                    select sum(T2.NoOfBytes),T1.Port  as P from (select Port,LinkID from LINK_APP_TBL where LinkID=LID) as T1,MAIN_TBL T2 where T1.LinkID=T2.LinkID and (T1.Port=T2.SourcePort or T1.Port=T2.DestPort ) and time_to_sec(timediff(current_timestamp,insertTime))<=240*60*60 group by 2 order by 1 desc limit 5;
            DECLARE CONTINUE HANDLER FOR NOT FOUND SET done1 = TRUE;
            open cur2;
            rl2:LOOP
                    fetch cur2 INTO PORT;
                    IF done1=TRUE THEN
                            LEAVE rl2;
                    END IF;
                    call temp_scale(LID,PORT);
            END LOOP;
            close cur2;
    END LOOP;
    close cur1;
    END$$

我收到第二个继续处理程序的错误。我刚从网上学习游标,所以不太清楚。

4

0 回答 0