zoukankan      html  css  js  c++  java
  • oracle 存储过程之游标(loop)使用

    declare --声明两个变量
    v_id VARCHAR2(50);
    v_int number;
    cursor yb is
    select a.id from T_D5_PUNISHMENT a where a.removed = '0';
    begin
    v_int := 1;           --变量赋值
    open yb;             --打开游标
    loop --开始标记
    fetch yb into v_id;         --游标赋值 当然这边可以赋值多个值
    (譬如:fetch yb into v_id , v_name;)
    exit when yb%notfound;             --游标一条一条地遍历记录,当找不到记录时退出
    begin
    update T_D5_PUNISHMENT a set a.cardtype= case a.cardtype when '02' then '01' when '03' then '02' when '04' then '05' else '' end             --实际操作
    where a.id=v_id;
    exception                                          --异常抛出
    when others then
    dbms_output.put_line(v_id);
    end;
    v_int := v_int+1;
    if(v_int >=500) then
    commit;                                 --500条提交一次 分单系统压力,提高上传的效率
    v_int :=0;
    end if;
    end loop;                    --结束标记
    commit;
    close yb;                   --关闭游标
    end;                     --结束
    / --这个斜杠用处很大,比如好多条存储过程的话,可以写在后面一起执行。


    ————————————————
    原文链接:https://blog.csdn.net/z1729734271/java/article/details/52351700

  • 相关阅读:
    iscroll.js & flipsnap.js
    IE8’s Substr() Bug
    chrome扩展,如何阻止浏览自动关闭桌面通知.
    临时邮箱
    多个显示器, window.open的定位
    页面刷新
    PipelineDB Install and Test
    CitusDB UPSERT
    Kafka部署
    ambari-cassandra-service
  • 原文地址:https://www.cnblogs.com/bbq668/p/13355381.html
Copyright © 2011-2022 走看看