1. 程式人生 > >oracle儲存過程把查詢到的值更新到別的表

oracle儲存過程把查詢到的值更新到別的表

create or replace procedure update_nst_t_Clime2
       as

             cursor c_db is 
             select * from NST_T_FRAME  f 
                left join (select substr(cname,0,2) as cname,cname as realname,cid from nst_t_Clime) c
                on  f.framename like ('%'||c.cname||'%支公司%')
                
where c.realname is not null and f.FRAMETYPE<>2 and f.FRAMETYPE<>1 union select * from NST_T_FRAME f left join (select substr(cname,3,2) as cname,cname as realname,cid from nst_t_Clime) c
on f.framename like ('%'||c.cname||'%分公司%') where f.FRAMETYPE=2 and c.realname is not null; begin for temp in c_db loop update nst_t_Clime set frameid= temp.frameid where cid= temp.cid and frameid is
null; end loop; end; --執行這個儲存過程: Begin update_nst_t_Clime2(); end;