oracle的双重for循环

前端之家收集整理的这篇文章主要介绍了oracle的双重for循环前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、需要用到游标:


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

猜你在找的Oracle相关文章