Switch Stage in Datastage:
Let’s try to configure this Switch stage.
Consider following table
Step 1: Design your job Structure like below.

Configure input Sequential file sf_emp_det with above table.
Step 2:Now, to configure Switch stage, double click on it. Following window will pop up.

There are three categories under ‘Properties’ tab.
Step 3:
defined Mappings’.
For record ID=8 will get discarded. For discarded value, ‘Link Label’
could be anything. Here is 5. Those records which are not matched with
case’s get rejected and stored it in ‘Reject link’, here ‘rjct_id_4’.

3. Options:
Discard value: This is like giving the ‘link label’ to discarded link. Consider our case, ‘case=8=5’. For record ID=8 will get routed to the link 5 which is mentioned here as ‘Discarded value’.
If not found: It decides action to be taken on the records which are failed to match with case statement.
Step 4: Let’s see what will happen to the output!!
Compile and run the job. We will see output link by link.




- Switch stage is a Processing Stage. It has one Input Link and number of output links depending upon the ‘cases’ mentioned. Maximum it can have 128 numbers of output links and one reject link.
- Function of Switch stage in Datastage is analogues to the Switch Statement in ‘C’ Language. For specific output required, there is specific ‘Case’ situation. As it has one Reject Link, those records which are not matched with any of the case will move to the reject link.
Let’s try to configure this Switch stage.
Consider following table
ID
|
First Name
|
Last Name
|
Location
|
Network ID
|
EmailID
|
1
|
Jach
|
Simmons
|
LA
|
JS524
|
Letsc@gmail.com
|
2
|
Shumas
|
Jane
|
Las
|
Sj145
|
Jaene@ymail.com
|
3
|
Jonty
|
Waughn
|
Syd
|
JW927
|
JontyW@sdbh.com
|
3
|
Suhana
|
Safar
|
Mexico
|
SS99
|
Sas@gmail.com
|
8
|
Abc
|
Cde
|
Mex
|
ab254
|
lmn@gmail.com
|
4
|
Shumas
|
Jane
|
Las
|
Sj145
|
Jaene@ymail.com
|

Configure input Sequential file sf_emp_det with above table.
Step 2:Now, to configure Switch stage, double click on it. Following window will pop up.

There are three categories under ‘Properties’ tab.
- Input
- User-defined Mapping
- Options
Step 3:
- Input: ‘Selector’ is field through which we have to select a column according to which ‘cases’ are going to be decide. Here, ‘Selector’ = ID.
defined Mappings’.
- User-defined Mappings: Here we are going to actually decide the case statements. As shown above, for case 1, 2, 3 and 8 are all ‘ID’ values and 0, 1, 2 are all link labels which we are getting from ‘Link Ordering’ tab.
ID
|
Link Label
|
Link Name
|
|
Case
|
1
|
0
|
lnk_ID_1
|
Case
|
2
|
1
|
lnk_ID_2
|
Case
|
3
|
2
|
lnk_id_3
|
Case
|
8
|
5(Discard Value)
|

3. Options:
Discard value: This is like giving the ‘link label’ to discarded link. Consider our case, ‘case=8=5’. For record ID=8 will get routed to the link 5 which is mentioned here as ‘Discarded value’.
If not found: It decides action to be taken on the records which are failed to match with case statement.
- Drop: It will drop the entire row
- Fail: It will cause the job to fail.
- Output: It will route that particular row to the reject link.
Step 4: Let’s see what will happen to the output!!
Compile and run the job. We will see output link by link.
- Link lnk_ID_1 for which ‘Case=1=0’.

- Link lnk_ID_2 for which ‘Case=2=1’.

- Link lnk_id_3 for which ‘Case=3=2’.

- For Reject link lnk_rjct_id_4 :As we didn’t mention any case statement for ID=4, it will get route to the reject link.

- For ‘Case=8=5’: Record for ID=8 get discarded.
No comments:
Post a Comment