zoukankan      html  css  js  c++  java
  • mysql 存储过程 REPEAT ... UNTIL ... END REPEAT

    begin
       declare  b int;
       declare  use_no    varchar(10);
       declare  use_name  varchar(400);
       declare  card_id   varchar(400);
       declare  count     int;
       declare  cur_1  cursor for
                                                         select s2.member_id,
                                                                        s2.realname,
                                                                        s2.card_id
                                                            from  bh_member.mb_member s1,bh_member.mb_member_info s2
                                                            where s1.id = s2.member_id;
       -- DECLARE CONTINUE HANDLER FOR NOT FOUND SET b=1;
        SET b = 0;
        -- (1) sql 赋值
        select count(1)  INTO count  
            from   bh_member.mb_member s1,bh_member.mb_member_info s2
          where  s1.id = s2.member_id;
       
       
        OPEN cur_1;    -- 打开游标
        REPEAT
              -- 从游标中循环取值
            FETCH cur_1 INTO use_no, use_name, card_id;

            insert into zh_ceshi(use_no,use_name,card_id)  values(use_no, use_name, card_id);
            set b = b+1;
            UNTIL  b = count        (不加分号)
        END REPEAT;
        close cur_1;          -- 关闭游标
    end

  • 相关阅读:
    501. Find Mode in Binary Search Tree
    [leetcode]Evaluate Reverse Polish Notation
    [leetcode]LRU Cache
    [mock]12月27日
    [mock]12月28日
    [leetcode]Max Points on a Line
    *[topcoder]JumpFurther
    [mock]12月11日
    *[topcoder]GUMIAndSongsDiv1
    [leetcode]Reorder List
  • 原文地址:https://www.cnblogs.com/zhuyeshen/p/12080394.html
Copyright © 2011-2022 走看看