Wednesday, 26 November 2014

Load Last N Records of File into Target Table - Informatica

How to load only the last N rows from source file into the target table using the mapping in informatica?
First take a look at the below data in the source file:
Products
--------
Windows
Linux
Unix
Ubuntu
Fedora
Centos
Debian
I want to load only the last record or footer into the target table. The target should contain only the product "Debain". Follow the below steps for implementing the mapping logic in informatica:
  • The mapping flow and the transformations are shown below:
SRC->SQ->EXPRESSION->SORTER->EXPRESSION->FILTER->TGT
  • Create a new mapping and drag the source into the mapping. By default, it creates the source qualifier transformation.
  • Now create an expression transformation and drag the ports from source qualifier into the expression transformation. In the expression transformation, create the below additional ports and assign the corresponding expressions:
v_count (variable port) = v_count+1
o_count (output port) = v_count
  • The output of expression transformation is
Products, o_count
-----------------
Windows, 1
Linux,   2
Unix,    3
Ubuntu,  4
Fedora,  5
Centos,  6
Debian,  7
  • Now connect the expression transformation to a sorter transformation and sort the rows on the o_count port in descending order. The output of sorter transformation is shown below:
Products
--------
Debian
Centos
Fedora
Ubuntu
Unix
Linux
Windows
  • Create another expression transformation and connect the Products port of sorter to expression transformation. Create the following ports in the expression transformation:
v_count (variable port) = v_count+1
o_count (output port) = v_count
  • Connect the expression to a filter transformation and specify the filter condition as o_count = 1.
  • Connect the filter to the target and save the mapping.

Informatica online training - Informatica Jobs

1 comment:

  1. Awesome blog its very informative and useful blog thanks for sharing. Know more about Informatica Online Training

    ReplyDelete