CREATE DEFINER=`root`@`localhost` PROCEDURE `assign_role_users`()
BEGIN
  declare user_id int;
  declare loop1ctr int default 0;
  declare not_found int default 0;
  declare r_user_id cursor for select id from users where is_admin=0;
  declare continue handler for not found set not_found:=1;
  open r_user_id;
  loop1:loop
    SET loop1ctr:=loop1ctr+1;
    /*SELECT loop1ctr;*/
    fetch r_user_id into user_id;
    if not_found=1 then
      close r_user_id;
      leave loop1;
    end if;
  INSERT INTO role_user VALUES  (3,user_id);
  end loop loop1;
END