日期:2014-05-17 浏览次数:20717 次
create procedure procedure_test is
declare @rcode varchar2(8);
declare @rname varchar2(60);
declare @html blob;
declare @duty varchar2(240);
begin
declare cur1 cursor for
select * from table_test1;
open cur1;
fetch next from cur1 into @rcode, @rname, @html, @duty;
WHILE @@FETCH_STATUS = 0
begin
if(select count(*) from table_test2 where rcode = @rcode)
update twriskdutyinfo set rname = cast((select rname from table_test2 a where a.rcode = @rcode) as varchar2(60)) where rcode = @rcode;
fetch next from cur2 into @rcode, @ranme, @html, @duty;
end
close cur1;
deallocate cur1;
end
create or replace procedure procedure_test is
v_rname varchar2(60);
begin
for i in (select rcode from table_test1) loop
select rname into v_rname from table_test2 a where a.rcode = i.rcode and rownum <=1;
update twriskdutyinfo set rname = NVL(v_rname,rname) where rcode = i.rcode;
end loop;
commit;
end;