Oracle11g的Merge很强大!

 1 create or replace procedure BRANCE_REPORT_MERGE is
 2 
 3 begin
 4   Merge into BRANCHREPORT desttable
 5   using TEMP_BRANCHREPORT tmptable
 6   on (desttable.SENDER_ID=tmptable.SENDER_ID and desttable.BRANCH_ID=tmptable.BRANCH_ID and  desttable.REPORT_TIME=tmptable.REPORT_TIME)
 7   when not Matched then
 8     insert (desttable.SENDER_ID,desttable.BRANCH_ID,desttable.REPORT_TIME) 
 9     values (tmptable.SENDER_ID,tmptable.BRANCH_ID,tmptable.REPORT_TIME);
10     
11     Execute IMMEDIATE 'TRUNCATE TABLE TEMP_BRANCHREPORT ';
12 end BRANCE_REPORT_MERGE;

由于每次获取的数据包中存在冗余、重复的数据,所以把数据存储在临时表中,到达一定数量则往主表中更新。记录存在不更新,不存在则更新。

相关文章:

  • 2022-12-23
  • 2021-08-26
  • 2021-08-31
  • 2022-12-23
  • 2021-06-02
  • 2021-11-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2022-12-23
  • 2021-06-21
  • 2021-09-17
相关资源
相似解决方案