HOW CAN YOU DO SCD2 IN DATA STAGE USING SEQUENTIAL FILES?



HOW CAN YOU DO SCD2 IN DATA STAGE USING SEQUENTIAL FILES?..

Answer / abhisek

Read the incoming records through any input stage like sequential file/dataset/table.
• Do the required processing for the incoming data.
• After the above processing step, pass the data into the change capture stage.
• The change capture should be having two input links- one is the before dataset and the other is the after dataset. For our job, the before dataset should be the active records present in the table. The active records are all those records which are having EXPR_DT=’2999-12-31’. The after dataset will be the incoming data passed into change capture after all the necessary processing.
• The change capture stage compared the before dataset and after dataset and produces 4 change_codes for each of the records. The 4 change codes are as follows:
“0” – Copy code (The code indicates the after record is a copy of the before record)
“1”-Insert code (The code indicates a new record has been inserted in the after set that did not exist in the before set.)
“2”-Delete code(The code indicates that a record in the before set has been deleted from the after set)
“3”-Edit code(the code indicates the after record is an edited version of the before record)
The copy records are not passed in the change captured stage as since we need only edited, insert records fro SCD II implementation.
• Use a filter stage to separate the records that needs to be expired and inserted.
• Filter the records with change_code = “1 or 3” into the insert records link. Filter the records with change_code=” 3” into update/expiry link.
• The records with change_code=3 are edited records. So the original records corresponding to these edited records are to be made in-active (expired). We can make the records inactive by changing the EXPR_DT<> ‘2999-12-31’.So to make the record inactive change the EXPR_DT with a valid date. For e.g. you can use make the EXPR_DT as the date one less than the date on which you are loading the data into the table. We will assume that we are loading the data on 2008-08-15.So the EXPR_DT for inactive records would become ‘2008-08-14’. The date 2008-08-15 can be made as the EFCT_DT for records to be inserted.
• To get the original records which needs to be expired, “look-up” the target table for all the records with change_code=3 which are filtered out separately. Get the original record along with the EFCT_DT of the original record. Then update the records EXPR_DT to ‘2008-08-14’ in the table. Now the original records are made inactive (expired).
• The new updated record (change_code=3) needs to be in table along with the new insert records(change_code=1).This data is filtered out from the “filter” stage and inserted into the table with EFCT_DT=”Data of loading” i.e. “2008-08-15” and EXPR_DT=”2999-12-31”

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Data Stage Interview Questions

How to convert table data into xml file using xml output stage? please explain step by step;

2 Answers   IBM,


what is the diff b/w switch and filter stage in datastage

2 Answers   Cap Gemini,


what is sparse lookup?

7 Answers   IBM,


What is the version control how can i apply this in DataStage can any one tell me the anser

4 Answers   IBM,


Hi, I have 3 records, 1 Srini 1 vasa 2 reddy now i want o/p like this 1 Srinivasa 2 reddy could u please help in this Thanks in advance.

6 Answers   Teradata,






What is the project in datastage?

0 Answers  


Why do we use link partitioner and link collector in datastage?

0 Answers  


Difference between IBM DATA STAGE8.5 and DATA STAGE9.1 ?

0 Answers   ABC, TCS,


How to display errors in datastage?

1 Answers   TCS,


To see hidden files in LINIX?

0 Answers   CTS,


Hi I have scenario like this s/r table T/r table ename,sal empno,ename,sal vijay,2000 1 , vijay, 2000 kumar,3000 2 ,kumar , 3000 ravi ,4000 3 ,ravi , 4000 How can i get target table like that without using Transformer stage?

8 Answers   Semantic Space,


Hi Friends, I have a input data like, class_id Marks 101 50 101 60 101 40 102 90 102 35 And i want my output data like class_id Marks Rank 101 50 2 101 60 1 101 40 3 102 90 1 102 35 2 how to do this in datastage?

8 Answers   Cognizant, HCL, TIAA CREF,


Categories