zoukankan      html  css  js  c++  java
  • AP_MergeSql

    SELECT 'Rows updated:',COUNT(1) FROM (SELECT 1 FROM DELTA.PRMCN WHERE ETL_FLAG IN ('A','D')) S;
    
    --重跑:删除已跑入数据
    DELETE FROM CCRD.PRMCN WHERE JOB_SEQ_ID= New_JOB_SEQ_ID;
    
    --重跑:从历史表恢复数据
    INSERT INTO CCRD.PRMCN(CATEGORY,CATE_DESC,CURR_NUM2,PROC_DAYS,BRANCH,PDCAT_FLAG,EFF_DT,END_DT,JOB_SEQ_ID)
    select CATEGORY,CATE_DESC,CURR_NUM2,PROC_DAYS,BRANCH,PDCAT_FLAG,EFF_DT,END_DT,JOB_SEQ_ID
    from ODSHIS.PRMCN WHERE NEW_JOB_SEQ_ID= New_JOB_SEQ_ID;
    
    --重跑:删除已跑入历史数据
    DELETE FROM ODSHIS.PRMCN WHERE NEW_JOB_SEQ_ID= New_JOB_SEQ_ID;
    
    --备份数据到历史表
    SELECT 'Rows readed:',COUNT(1),'Rows changed:',COUNT(1) FROM (SELECT 1 FROM DELTA.PRMCN WHERE ETL_FLAG IN ('I','A','D')) S;
    SELECT 'Rows updated:',COUNT(1) FROM NEW TABLE (
    INSERT INTO ODSHIS.PRMCN(CATEGORY,CATE_DESC,CURR_NUM2,PROC_DAYS,BRANCH,PDCAT_FLAG,EFF_DT,END_DT,JOB_SEQ_ID,NEW_JOB_SEQ_ID)
    select CATEGORY,CATE_DESC,CURR_NUM2,PROC_DAYS,BRANCH,PDCAT_FLAG,EFF_DT,END_DT,JOB_SEQ_ID,New_JOB_SEQ_ID
    from CCRD.PRMCN T
    WHERE T.END_DT='9999-12-31' AND EXISTS ( SELECT 1 FROM DELTA.PRMCN S
    WHERE T.CATEGORY=S.CATEGORY )
    );
    
    --断链
    MERGE INTO CCRD.PRMCN T 
    USING (SELECT * FROM DELTA.PRMCN WHERE ETL_FLAG IN ('I','D','A')) S
    ON T.CATEGORY=S.CATEGORY  AND T.END_DT='9999-12-31'
    WHEN MATCHED THEN UPDATE SET 
    T.END_DT='#DATEOFDATA#', T.JOB_SEQ_ID= New_JOB_SEQ_ID;
    
    --加链
    INSERT INTO CCRD.PRMCN(CATEGORY,CATE_DESC,CURR_NUM2,PROC_DAYS,BRANCH,PDCAT_FLAG,EFF_DT,END_DT,JOB_SEQ_ID)
    select CATEGORY,CATE_DESC,CURR_NUM2,PROC_DAYS,BRANCH,PDCAT_FLAG,'#DATEOFDATA#','9999-12-31',New_JOB_SEQ_ID
    from DELTA.PRMCN where ETL_FLAG in ('A','I');
    
    --保持数据完整性
    MERGE INTO CCRD.PRMCN T 
    USING (SELECT * FROM DELTA.PRMCN WHERE ETL_FLAG = 'D' ) S
    ON T.CATEGORY=S.CATEGORY 
    WHEN NOT MATCHED THEN 
    INSERT (CATEGORY,CATE_DESC,CURR_NUM2,PROC_DAYS,BRANCH,PDCAT_FLAG,EFF_DT,END_DT,JOB_SEQ_ID)
    VALUES (CATEGORY,CATE_DESC,CURR_NUM2,PROC_DAYS,BRANCH,PDCAT_FLAG,'#DATEOFDATA#','#DATEOFDATA#',New_JOB_SEQ_ID);

    以上就是对数据进行做拉链加载

  • 相关阅读:
    Delphi中解析Xml的控件-SimDesign NativeXml
    DELPHI判断是否64位操作系统
    几个获取Windows系统信息的Delphi程序
    delphi假死线程堵塞解决办法
    Delphi ADO数据操作封装类
    Delphi的时间与字符串函数代码示例
    【BZOJ2132】圈地计划 最小割
    【BZOJ3544】[ONTAK2010]Creative Accounting 前缀和+set
    【BZOJ4281】[ONTAK2015]Związek Harcerstwa Bajtockiego LCA
    【BZOJ2083】[Poi2010]Intelligence test 二分
  • 原文地址:https://www.cnblogs.com/Jims2016/p/7425262.html
Copyright © 2011-2022 走看看