代码之家  ›  专栏  ›  技术社区  ›  Himanshu

无法实现SCD2

  •  0
  • Himanshu  · 技术社区  · 4 年前

    我只是在研究SCD类型2,无法以某些场景没有完全填满的方式完全实现它。我在IICS做过。真的很难涵盖所有可能的情况。因此,流程如下:

    Src 
    ---> Lkp ( on src.id = tgt.id)
     ---> expression ( flag= iif (isnull (tgt.surrogatekey) then Insert, iif(isnotnull(tgt.surrogatekey) and md5(other_non_key_cole)<>tgt.md5)then Update) 
    ----> insert on flag insert(works fine) 
    but on update i pass updates
     to 2 target instances 
    of same target table
    in one i am updating it 
    as new update as insert 
    and in other i
    am updating tgt_end_date=lkp_start_date for previously stored ids and active_ind becomes 'N'. 
    

    但是,当我再次接收到具有相同记录的新更新(意味着重复)时,这是有效的,或者只是重新运行映射在目标表中插入重复项,并且end_date的更改也变得不稳定。当我插入同一记录的多个更改时,它将所有active_flags设置为“Y”,预期的值应该是“N”,除了上次运行的最新记录。如果你能解释的话,有人能帮忙吗?即使是在SQL中。

    0 回复  |  直到 4 年前
        1
  •  -1
  •   NickW    4 年前

    如果我正确理解了你的问题,那么在每次跑步中,你的源中都有多条记录与目标中的一条记录相匹配。

    如果是这种情况,那么您需要处理数据,以便在将数据放入SCD2过程之前,每个目标记录都有一个源记录

    推荐文章