Tuesday, February 26, 2013

Normalizer Transformation

  • Active and Connected Transformation.
  • The Normalizer transformation normalizes records from COBOL and relational sources, allowing us to organize the data.
  • Use a Normalizer transformation instead of the Source Qualifier transformation when we normalize a COBOL source.
  • We can also use the Normalizer transformation with relational sources to create multiple rows from a single row of data.
Example 1: To create 4 records of every employee in EMP table.
  • EMP will be source table.
  • Create target table Normalizer_Multiple_Records. Structure same as EMP and datatype of HIREDATE as VARCHAR2.
  • Create shortcuts as necessary.
Creating Mapping :
  1. Open folder where we want to create the mapping.
  2. Click Tools -> Mapping Designer.
  3. Click Mapping-> Create-> Give name. Ex: m_ Normalizer_Multiple_Records
  4. Drag EMP and Target table.
  5. Transformation->Create->Select Expression-> Give name, Click create, done.
  6. Pass all ports from SQ_EMP to Expression transformation.
  7. Transformation-> Create-> Select Normalizer-> Give name, create & done.
  8. Try dragging ports from Expression to Normalizer. Not Possible.
  9. Edit Normalizer and Normalizer Tab. Add columns. Columns equal to columns in EMP table and datatype also same.
  10. Normalizer doesn’t have DATETIME datatype. So convert HIREDATE to char in expression t/f. Create output port out_hdate and do the conversion.
  11. Connect ports from Expression to Normalizer.
  12. Edit Normalizer and Normalizer Tab. As EMPNO identifies source records and we want 4 records of every employee, give OCCUR for EMPNO as 4.
  13. clip_image002
  14. Click Apply and then OK.
  15. Add link as shown in mapping below:
  16. Mapping -> Validate
  17. Repository -> Save
  • Make session and workflow.
  • Give connection information for source and target table.
  • Run workflow and see result.
Example 2: To break rows into columns
Source:
Roll_NumberNameENGHINDIMATHS
100Amit787690
101Rahul767887
102Jessie659879


Target :
Roll_NumberNameMarks
100Amit78
100Amit76
100Amit90
101Rahul76
101Rahul78
101Rahul87
102Jessie65
102Jessie98
102Jessie79

  • Make source as a flat file. Import it and create target table.
  • Create Mapping as before. In Normalizer tab, create only 3 ports Roll_Number, Name and Marks as there are 3 columns in target table.
  • Also as we have 3 marks in source, give Occurs as 3 for Marks in Normalizer tab.
  • Connect accordingly and connect to target.
  • Validate and Save
  • Make Session and workflow and Run it. Give Source File Directory and Source File name for source flat file in source properties in mapping tab of session.
  • See the result.


No comments:

Post a Comment