存储过程及游标使用

与世无争的帅哥 提交于 2019-12-17 03:01:30

存储过程及游标使用

实现test2表向test1表同步

create or replace procedure procedure_test as
  v_id armcp.test2.id%Type;
  v_c1 armcp.test2.c1%Type;
  cursor cursor_test2 is(
    select t2.id, t2.c1 from test2 t2);
begin
  open cursor_test2;
  loop
    fetch cursor_test2
      into v_id, v_c1;
    update test1 t1 set t1.c1 = v_c1 where t1.id = v_id;
    exit when cursor_test2%notfound;
  end loop;
  commit;
  close cursor_test2;
end;

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!