欢迎投稿

今日深度:

oracle通过存储过程实现表间字段迁移

oracle通过存储过程实现表间字段迁移


oracle通过存储过程实现表间字段迁移
 
条件:
两个表:
ITPUB_TEST1 字段 id,value 
ITPUB_TEST2 字段 id,funcid ,action
 
ITPUB_TEST2  的funcid 关联ITPUB_TEST1 中的id。
 
任务:
将ITPUB_TEST2 中的action内容 迁移到对应ITPUB_TEST1的value字段。(funcid对应id)
[sql] 
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;  

 

[sql] 
  
[sql] 
执行:  
[sql] 
exec transfer();  
 

www.htsjk.Com true http://www.htsjk.com/oracle/21018.html NewsArticle oracle通过存储过程实现表间字段迁移 oracle通过存储过程实现表间字段迁移 条件: 两个表: ITPUB_TEST1 字段 id,value ITPUB_TEST2 字段 id,funcid ,action ITPUB_TEST2 的funcid 关联ITPUB_TEST1 中的id。...
相关文章
    暂无相关文章
评论暂时关闭