Mysql stored procedure error: ERROR 1337 (42000): Variable or condition declaration after cursor

Error message:

ERROR 1337 (42000): Variable or condition declaration after cursor or handle

wrong reason:

All declared variables should be placed after the cursor

solve:

    DECLARE name VARCHAR(64);
     -- traverse the end of data flag
    DECLARE done INT DEFAULT FALSE;
    DECLARE tables_cur CURSOR FOR select 。。。;
    -- bind the end marker to the cursor
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

There are two concepts in it:

cursor 和 handler

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327038558&siteId=291194637