oracle的双重for循环

来源:互联网 发布:往事知多少是什么意思 编辑:程序博客网 时间:2024/05/01 05:15

1、需要用到游标:


create or replace procedure test_procedure is  --a表游标定义  cursor a_cursor is  select substr(mc,0,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;


0 0
原创粉丝点击