CREATE DEFINER="cw"@"%" PROCEDURE "removeTasks"()
BEGIN
declare v_taskid int;
declare done int default 0;
declare cur1 cursor for
select taskid
from task
where /*ADD CONDITIONS*/;
declare continue handler for not found set done=1;
set done = 0;
open cur1;
taskLoop: loop
fetch cur1 into v_taskid;
if done = 1 then leave taskLoop; end if;
call removeTaskById(v_taskid);
end loop taskLoop;
close cur1;
END