declare
--声明游标
cursor source_table is
select 字段A,字段B from A表;
--声明游标变量
rec_source_table source_table%rowtype;
begin
--判断游标是否被打开,如果已经打开,首先关闭
if source_table%isopen then
--关闭游标
close source_table;
end if;
--打开游标
open source_table;
--进行循环
loop
--打开游标里的一条记录,赋到游标变量里
fetch source_table
into rec_source_table;
--判断游标里是否还有记录,如果没有记录,关闭游标,退出循环
if source_table%notfound then
close source_table;
exit;
else
update B表 set B表的字段A=rec_source_table.字段b where zgh=rec_source_table.zgh;
commit;
end if;
end loop;
exception
when others then
rollback;
end;
--声明游标
cursor source_table is
select 字段A,字段B from A表;
--声明游标变量
rec_source_table source_table%rowtype;
begin
--判断游标是否被打开,如果已经打开,首先关闭
if source_table%isopen then
--关闭游标
close source_table;
end if;
--打开游标
open source_table;
--进行循环
loop
--打开游标里的一条记录,赋到游标变量里
fetch source_table
into rec_source_table;
--判断游标里是否还有记录,如果没有记录,关闭游标,退出循环
if source_table%notfound then
close source_table;
exit;
else
update B表 set B表的字段A=rec_source_table.字段b where zgh=rec_source_table.zgh;
commit;
end if;
end loop;
exception
when others then
rollback;
end;