Switch stage in Datastage : Quick Example 

Switch stage in Datastage : Quick Example 

The Switch Stage in DataStage allows implementing the case switch concept of C programming language which allows controlling the flow of records as per the cases. It can have one reject, one input, and 128 output links

Records which are not satisfying any case will be passed to reject link.

 

Example Operation:

Consider the Following case switch function example.

switch (SALARY)
{
   case 1000:          // if SALARY = 0,
            // write  to output data set 2
            break;
   case 2000:          // if SALARY = 10,
            // write to output data set 3
            break;

   case default:             // if  salary is  not in 1000 or 2000 then,
               // send records to reject link Dataset_4
};

 

Properties

Category/Property Values
Input/Selector Input column
Input/Case Sensitive True/False
Input/Selector Mode User-defined mapping/Auto/Hash
User-defined Mapping/Case String
Options/If not found Pathname
Options/Discard Value String


Properties tab:

  1. Specify the input column to be used in Selector
  2. Case conditions are defined in the properties.Example Case: 0 =0 means that if input column has value 0, then records will be passed first to link specified in link ordering tab.Case:10=1 means that if the input column value is ten, then records will be given to the second link
Switch Stage in Properties
Switch Stage Properties in Datastage
  1. If not found then records will be directed to reject link
Switch stage link ordering tab
Switch stage link ordering tab

Working Example

Job design: 

Switch stage in datastage job
Switch stage in datastage job

Input data set:

Funnel stage : input data set
Switch stage : input data set

PROPERTIES SET UP:

Funnel stage : Properties Tab
Switch stage : Properties Tab
Switch stage : mapping tab
Switch stage : mapping tab

Output data set:

Switch stage : output dataset 1
Switch stage : output dataset 1

Switch stage : output dataset 2Switch stage : output data set 2

 Related topic

Difference between switch and filter

 

Share this post

Leave a Reply