存储过程修复数据


--refresh_accounter_no_1(刷新账套表的用户编号)
BEGIN
  DECLARE temp_id INT;
  DECLARE temp_accounter_id INT;
  DECLARE temp_accounter_no VARCHAR(64);
    DECLARE state VARCHAR(30);
    DECLARE account_book_cursor CURSOR FOR SELECT id,accounter_id FROM account_book;
    DECLARE CONTINUE HANDLER FOR 1329
    BEGIN
        SET state = 'error';
    END; 
  OPEN account_book_cursor;
  REPEAT
        FETCH account_book_cursor INTO temp_id,temp_accounter_id;
        SELECT no INTO temp_accounter_no FROM account WHERE id = temp_accounter_id;
        UPDATE account_book SET accounter_no = temp_accounter_no WHERE id = temp_id;
        UNTIL state = 'error'
    END REPEAT;
    CLOSE account_book_cursor;
END

--refresh_accounter_no_2(刷新日志表的用户编号)
BEGIN
  DECLARE temp_id INT;
  DECLARE temp_accounter_id INT;
  DECLARE temp_accounter_no VARCHAR(64);
    DECLARE state VARCHAR(30);
    DECLARE operation_log_cursor CURSOR FOR SELECT id,accounter_id FROM operation_log;
    DECLARE CONTINUE HANDLER FOR 1329
    BEGIN
        SET state = 'error';
    END; 
    OPEN operation_log_cursor;
  REPEAT
        FETCH operation_log_cursor INTO temp_id,temp_accounter_id;
        SELECT no INTO temp_accounter_no FROM account WHERE id = temp_accounter_id;
        UPDATE operation_log SET accounter_no = temp_accounter_no WHERE id = temp_id;
        UNTIL state = 'error'
    END REPEAT;
    CLOSE operation_log_cursor;
    SELECT temp_id,temp_accounter_id,temp_accounter_no;
END

优质内容筛选与推荐>>
1、一款基于ExoPlayer的自定义播放器(已开源)
2、Java--类和对象之初始化和清除
3、看我如何逆向智能手环控制无人机
4、Java虚拟机工作原理
5、《神经网络》中文字幕版|(3.线性/逻辑神经网络和反向传播)


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号