mysql存储过程游标

delimiter $$
CREATE PROCEDURE `makeMax`(in step int)
BEGIN
  DECLARE u_ids varchar(32);
  DECLARE done INT DEFAULT FALSE;

  DECLARE cur CURSOR FOR select 500 as u_id union all select 600 as u_id;

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

  -- 打开游标
  OPEN cur;
  -- 开始循环
  read_loop: LOOP
        -- 提取游标里的数据
        FETCH cur INTO u_ids;
        -- 声明结束的时候

        IF done THEN
            LEAVE read_loop;
        END IF;
        select u_ids,step;
 END LOOP;
CLOSE cur;

END
$$;
call makeMax(100);
上一篇:mssql sqlserver 数据类型sql_variant简介说明


下一篇:如何在wordpress中的fonts.php之后加载style.css?