Saturday, September 28, 2013

informatica course

Wednesday, August 31, 2011

Informatica Real Time Scenerios


                   Split the non-key columns to separate tables with key column in both

Scenario 2:
Split the non-key columns to separate tables with key column in both  / How to split the data of source table column-wise with respect to primary key. See the source and target tables below.
source table: ID is the key column, Name and Phone No are non-key columns

ID
Name
Phone No
10
AAA
123
20
BBB
234
30
CCC
434
40
DDD
343
50
EEE
442
Target Table 1

ID
Name
10
AAA
20
BBB
30
CCC
40
DDD
50
EEE
Target Table 2 


ID
Phone No
10
123
20
234
30
434
40
343
50
442



Solution:
Step  1: Source qualifier: get the source table to the mapping area. See image below.


 
Step 2:  Drag all the port from (from the previous step) to the Aggregator transformation and group by the key column. Since we have to split the columns to two different tables with the key column in each, so we are going use two expression transformation, each will take the key column and one non-key column. Connect  aggregator transformation with each of the expression transformation as follows.

Step 3: We need another set of  aggregator to be associated with each of the expression tranformation from the previous step.
Step 4: In the final step connect the aggregators with the two target tables as follows.


Here is the iconic view of the entire mapping.



Separating duplicate and non-duplicate rows to separate tables


Scenario 3:
How to segregate the duplicate and distinct rows from source table to separate target tables?
source table:

COL1
COL2
COL3
a
b
c
x
y
z
a
b
c
r
f
u
a
b
c
v
f
r
v
f
r
Target Table 1: Table containing all the unique rows
COL1
COL2
COL3
a
b
c
x
y
z
r
f
u
v
f
r

Target Table 2: Table containing all the duplicate rows

COL1
COL2
COL3
a
b
c
a
b
c
v
f
r
Solution:
Step  1: Drag  the source to mapping and connect it to an aggregator transformation.

 
Step  2: In aggregator transformation, group by the key column and add a new port  call it count_rec to count  the key column.
Step  3: connect  a router to the  aggregator from the previous step.In router make two groups one named "original" and another as "duplicate"
In original write count_rec=1 and in duplicate write count_rec>1.



 
The picture below depicting group name and the filter conditions


 
Step 4: Connect two group to corresponding target table.


Remove footer from your file

Scenario 5: How to remove footer from your file ?

For example the file content looks like as below:-

some Header here
col1    col2    col3     col4
data1  data2  data3  data4
data5  data6  data7  data8
data1  data2  data3  data4
data1  data2  data3  data4
footer
Just we have to remove footer  from the file.
Solution:

Step1:  Drag the source to mapping area.


Step2: After that  connect a filter or router transformation.

Step3:   In filter write the condition  like  in the picture
Scenario6:
Get the first top five salaries with out using rank transformation


 
Step 4:Finally  pass it over to target.

Remove header from your file


Scenario 6: How to remove header from a file ?
Solution
Step1:  After mapping  go to workflow  and scheduled it.
Step2:  Just double click on the session  and go to mapping option.

 Step3:  Select  the source  and go to the set file properties.


flat file properties
Step4:Chose the advance option.  Set number of initial rows skip: 1 ( it can be more as per requirement )


Aggregating rows on group count basis

Scenario 13: There are 4 departments in Emp table. The first one with 100,2nd with 5, 3rd with 30 and 4th dept has 12 employees. Extract those dept numbers which has more than 5 employees in it,  to a target table.
Solution:
Put the source to mapping and connect the ports to aggregator transformation

Make 4 output ports in aggregator  as in the picture above : count_d10, count_d20, count_d30, count_d40.
For each port write expression like in  the picture below.






 


Then send it to expression transformation

  In expression make four output ports (dept10, dept20, dept30, dept40) to validate dept no
And provide the expression like in the picture below.


5. Then connect to router transformation. And create a group and fill condition like below.




6. Finally connect to target table having one column that is dept no.


 









Thursday, July 21, 2011

FTP ing the Files

#!/bin/sh


sftp USERNAME@LOCATION_OF_FILES

lcd FILES_DIRECTORY #it is the directory where your files received

cd desired_directory # it is the directory name where you want to put files

get Files

quit

EOC

Monday, July 18, 2011

Simple senario with solution

I have the source table is
  Number
1
1
2
3
3
4



Target_unique                   Target_Duplicates
    2                                                   1
    4                                                   3




Procedure :


>  Drag the source twise in the mapping designer.
> Drag the targets on the mapping designer.
> Create Aggregrator Transformation take the number as input port and count number take as output port with the condition is count(number).
> Create the joinner transformation drag the number port from source2 and drag the all ports from the aggregrator transformation.
> The condition in joinner transformation is number1=number.
> Create the router transformation with two groups
   *  Unique group have the condition is countnumber=1.
   * Duplicate group have the condition is countnumber>1.
> Link to the two targets.
> Create session and workflow.







CREATE THE SOURE TABLE AS

ID KITNO CODE
1  1      G1
2  2      G1
3  3      G1
4  4      G1
5  5      G2


TARGET TABLE IS

ID KITNO CODE
1  4      G1
2  4      G1
3  4      G1
4  4      G1
5  1      G2






 Procedure is

Drop the soure table twice in the mapping designer.
Drop the target table.
Create the aggregator transformation by the following logic
  1.Take kit no as input port.
  2. code as group by.
  3. create new port max count as output port with the condition is
     max(kit no).
Create the Normal joiner Transformation.
Drag the code and max count from the agg transformation.
Drag the id,kit no,code from the second source table.
create the condition in the joiner transformation code1=code.
Drag the ports from joiner transformation to target that are id,max count for kit no,code1 for code.
Create the session and work flow.                         

 


  Scenario - 2


Let say i have more than have record in source table and i have 3 destination table A,B,C. i have to insert first to 10 record in A then 11 to 20 in B 21 to 30 in c. Then again from 31 to 40 in A. 41 to 50 in B and 51 to 60 in c... so on up to last record.


Drag the source and target on maping desingner.
Create the exp transformations and copy the source ports to the exp transformation.
Double the exp trans and create new port seq_number.
Create the sequence generator transformation.
Link the nextvalue to the seq_number transfromation.
create Router transformation and drag the ports of exp transformation into router transoformation,
create the 3 groups and comming to logic is

Group1 = mod(seq_number,30) >= 1 and mod(seq_number,30) <= 10
Group2 = mod(seq_number,30) >= 11 and mod(seq_number,30) <= 20
Group3 = (mod(seq_number,30) >=21 and mod(seq_number,30) <= 29 ) or mod(seq_number,30) = 0
 

Connect the group one to first target,group two to the second target,third group to the third target.
Create the session and create workflow.



Wednesday, July 13, 2011

What is slowly changing Dimension?

Slowly changing dimension are dimension data, these dimensions increasing dimensions data with update existing dimensions.

Type1: Rows containing changes to existing dimensional are update in the target by overwriting the existing dimension. In the Type1 Dimension mapping, all rows contain current dimension data. Use the type1 dimension mapping to update a slowly changing dimension table when you do not need to keep any previous versions of dimensions in the table.

Type2: The Type2 Dimension data mapping inserts both new and changed dimensions into the target. Changes are tracked in the target table by versioning the primary key and creating a version number for each dimension in the table.Use the Type2 Dimension/version data mapping to update a slowly changing dimension when you want to keep a full history of dimension data in the table. Version numbers and versioned primary keys track the order of changes to each dimension.

Type3: The type 3 dimension mapping filters source rows based on user-defined comparisons and inserts only those found to be new dimensions to the target. Rows containing changes to existing dimensions are updated in the target. When updating an existing dimension the informatica server saves existing data in different columns of the same row and replaces the existing data with the updates.

Thursday, June 30, 2011

If i had source like unique & duplicate records like 1,1,2,3,3,4 then i want load unique records in one target like 2,4 and i want load duplicate records like 1,1,3,3


For Unique and Duplicate , we can go for same flow :
 
Source-->SrcQualifier-->Aggregator(group by this column and find count also)--> then use joiner (use 
the column from Source qualifier and join the data from Aggregator as source qualifier.col=aggregator.col) --> Router (insert into t1 for count>1 and for count=1 insert into t2). t1 is for duplicate records and it will cintain 1,1,3,3 and t2 will have 2,4.
 
Records in Source Q :
col 
1,1,2,3,3,4
 
The records after agregator will look like this :
col   count
1     2
2     1
3     2  
4     1
 
Records after Joiner : source q.col=aggregator.col
col count
1   2
1   2
2   1
3   2
3   2
4   1
 
These records will flow in router and we define two groups; one for count>1 (for duplicates record) and second for count=1 ( for unique record)

I have a scenario like - how can i load 1st record to Trgt1,2nd-Trgt2, 3rd->Trgt3 and again the cycle has to repeat with loading 4th-Trgt1,5th->Trgt2,6th->Trgt3?


Take a sequence generator with Start Value=1,Current 
Value=1,End Value=3, Increment By=1  to assign a seqno to 
each row. Do not forget to enable the cycle option.
 
after that take a Router with three groups of 
seqno=1,seqno=2 and seqno=3