mysql-預存程序 使用遊標擷取資料集並且操作

來源:互聯網
上載者:User

標籤:欄位   pass   procedure   fetch   操作   char   har   phone   --   

delimiter $create PROCEDURE phoneDeal()BEGIN    DECLARE  id varchar(64);   -- id    DECLARE  phone1  varchar(16); -- phone    DECLARE  password1  varchar(32); -- 密碼    DECLARE  name1 varchar(64);   -- id    -- 遍曆資料結束標誌    DECLARE done INT DEFAULT FALSE;    -- 遊標    DECLARE cur_account CURSOR FOR select phone,password,name from account_temp;    -- 將結束標誌綁定到遊標    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;        -- 開啟遊標    OPEN  cur_account;         -- 遍曆    read_loop: LOOP            -- 取值 取多個欄位            FETCH  NEXT from cur_account INTO phone1,password1,name1;            IF done THEN                LEAVE read_loop;             END IF;         -- 你自己想做的操作        insert into account(id,phone,password,name) value(UUID(),phone1,password1,CONCAT(name1,‘的家長‘));    END LOOP;      CLOSE cur_account;END $

 

mysql-預存程序 使用遊標擷取資料集並且操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.