条件:
两个表:
ITPUB_TEST1 字段 id,value
ITPUB_TEST2 字段 id,funcid ,action
ITPUB_TEST2 的funcid 关联ITPUB_TEST1 中的id。
任务:
将ITPUB_TEST2 中的action内容 迁移到对应ITPUB_TEST1的value字段。(funcid对应id)
create or replace procedure transfer as
Cursor cursor is select funcid,action from ITPUB_TEST2;
myVar varchar2(50);
begin
for myVar in cursor LOOP
begin
dbms_output.put_line(myVar.funcid);
dbms_output.put_line(myVar.action);
if(myVar.funcid != 0) then
dbms_output.put_line('ok');
update ITPUB_TEST1 set value=myVar.action where id=myVar.funcid;
end if;
end;
end LOOP;
commit;
end;
执行:
exec transfer();