加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle的双重for循环

发布时间:2020-12-12 16:14:08 所属栏目:百科 来源:网络整理
导读:1、需要用到游标: create or replace procedure test_procedure is --a表游标定义 cursor a_cursor is select substr(mc,2) as str,mc as mcs from t_bz_zd_xzqh_jc; --b表游标定义 cursor b_cursor(str1 string) is SELECT bm FROM t_bz_zd_xzqh where mc

1、需要用到游标:


create or replace procedure test_procedure is
  --a表游标定义
  cursor a_cursor is
  select substr(mc,2) as str,mc as mcs   from t_bz_zd_xzqh_jc;
  --b表游标定义
  cursor b_cursor(str1 string) is
    SELECT bm FROM t_bz_zd_xzqh where mc like  '%' || str1 || '%'; -- instr(mc,str1) > 0;
begin
  for a_cur in a_cursor loop
    for b_cur in b_cursor(a_cur.str) loop
      --这里是你要执行的操作,比如insert到c
      --insert into c values (b_cur.id);
      update t_bz_zd_xzqh_jc set bh= b_cur.bm where mc = a_cur.mcs ;
      commit;
    end loop;
  end loop;
  
  end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读