mysql 存儲過程、循環

CREATE PROCEDURE  questionProc()
BEGIN

 declare pgId int(11); 
 declare pGuid varchar(255);
 -- 定義遊標卡尺 declare done boolean DEFAULT TRUE; -- 獲取數據到遊標卡尺 DECLARE cur CURSOR FOR
select id,qid from tb_question; -- 打開遊標卡尺 OPEN cur;
  -- 開始循環 WHILE done
do FETCH cur INTO pgId,pGuid; update tb_question_item set question_id=pgId where qid= pGuid; end while; CLOSE cur; END; CALL questionProc();
相關文章
相關標籤/搜索