-- declare NOT FOUND handler declareCONTINUEHANDLER FORNOTFOUNDSET finished = 1;
OPEN appcursor; get_item: LOOP FETCH appcursor INTO appid,appname; IF finished = 1THEN LEAVE get_item; ENDIF; -- select appid,appname; -- select id,app_id,image_path from build_history where app_id=appid order by create_time desc limit 5; -- insert into latest_image(`app_id`,'app_name','app_image') values(appid,appname,appimage); insertinto latest_image(`app_id`,`app_image`) select app_id as app_id,image_path as app_image from build_history where app_id=appid orderby create_time desclimit num; ENDLOOP get_item; CLOSE appcursor;