You are on page 1of 2

SCD type-2 is a method to track historical data by retaining the full history of

values.
When the value of an attribute/ field changes, the current record is closed, and a
new record is created with the changed data value
which becomes the current record.

Effective Date Range Mapping


Version Data Mapping
Flag Current Mapping
###Source
SRC:
CUST_ID
CUST_NAME
CUST_ADDR
CUST_CONTACT

###Expression Transformation
EXP:
CUST_ID
CUST_NAME
CUST_ADDR
CUST_CONTACT
SRC_DELTA_CHK_SUM_NBR MD5(CUST_NAME|| CUST_ADDR || CUST_CONTACT)

LKP on CUSTOMER_TGT_TBL: (LKP_CONDITION (TGT.CUST_ID = SRC.CUST_ID))


(IN Lookup SQL OVERride, we need to generate SQL query and filer
condition EFF_END_DATE '9999-12-31'.
Here we are trying to pull active records from target table)
TGT_Surrogate_key
CUST_ID
CUST_NAME
CUST_ADDR
CUST_CONTACT
EFF_START_DATE
EFF_END_DATE
SRC_CUST_ID
DELTA_CHK_SUM_NBR

LKP to EXP : (TGT_Surrogate_key, CUST_ID, DELTA_CHK_SUM_NBR)


EXP to EXP:
TGT_Surrogate_key
LKP_CUST_ID
DELTA_CHK_SUM_NBR
CUST_ID
CUST_NAME
CUST_ADDR
CUST_CONTACT
EFF_START_DATE
EFF_END_DATE TO_DATE('9999-12-31', 'YYYY-MM-DD')
SRC_DELTA_CHK_SUM_NBR
SRC_CUST_ID
INS_UPD_FLG IIF(ISNULL(SRC_CUST_ID),'I',IIF(SRC_DELTA_CHK_SUM_NBR !=
DELTA_CHK_SUM_NBR),'U','G')

DRAG and DROP all ports to Router Transformation


In router, Add two conditions ..
INSERT_GRP INS_UPD_FLG = 'I'
UPDATE_GRP INS_UPD_FLG = 'U'

Seq_Generator
NEXTVAL
CURRVAL

UPdate Stratgey Tranformation:


UPdate Stratgey Expression DD_UPDATE

TGT_Surrogate_key

1.In target table we need three extra columns like


Surrogate_KEY,Effective_Start_Date,Effective_End_date.
2. If source record doesn’t exist in target then we need insert into
target,Dimension key with
surrogate key ,effective_stdt with system date and effective_Eddt with the future
date
3. If source record already present ,then compare source SCD columns with target
SCD
columns.

If there is any change in any of the column then we need to do two tasks
Task 1:Insert this as New record
Task2:Update previous existing active record end date with the sysdate
4. In Router we need create two groups one for Newly insert records and second one
for insert
and Update(Previous record effective end date with sysdate)
5. Lookup override write a query to fetch only active records into Cache

MD5 Function: Unique 32-character string of hexadecimal digits 0-9 and a-f.

You might also like