Oracle update set from where 批量update


--sql寫法:
update bcd_samplingrecord_detail
set Invalid=t.cin,hasfilter=t.ch
from (select recordid cid,Invalid cin,hasfilter ch from bcd_samplingrecord) t
where recordid=t.cid

--Oracle寫法:卡死人
update bcd_samplingrecord_detail t1
set (t1.Invalid,t1.hasfilter)=(select Invalid,hasfilter from bcd_samplingrecord t2 where t2.recordid=t1.recordid) 


--直接游標
begin
  for c in (select * from bcd_samplingrecord)
    loop
      update bcd_samplingrecord_detail 
      set Invalid=c.invalid,hasfilter=c.hasfilter
      where recordid=c.recordid;
    end loop;
end;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM