Monday 18 July 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.


Tuesday 12 July 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.

Wednesday 29 June 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

In EMP table, for those emp whose Hiredate is same, update their sal by "sal+500" or else for others keep the sal as it is, how to do it by SQL query


UPDATE emp
SET sal=sal+500
WHERE hiredate IN (SELECT hiredate
                                            FROM employees
                                             HAVING COUNT(*)>1
                            GROUP BY hiredate)

write a sql query to get the id and how many times its count of repetition and there u shouldn't get the distinct(i.e id-3)


I am having a table with columns
ID  NAME                                               
 1  x                                 And the requirement is to get the o/p like this  
 1  y                                 ID     Count(*)    
 1  z                                  1      3 
 2  a                                  2      2 
 2  b                                    
 3  c


The Query is:



select id,count(*) from group by id having count(*)>1;

Test Functions


5.1      ISNULL

The ISNULL function returns whether a value is NULL. It is available in the Designer and the Workflow Manager.
     ISNULL( value )
Example : The following example checks for null values in the items table:
ISNULL ISNULL ( ITEM_NAME )
ITEM_NAME
RETURN VALUE
Flashlight
0 (FALSE)
NULL
1 (TRUE)
''
0 (FALSE) Empty string is not NULL

5.2      IS_DATE

The IS_DATE function returns whether a value is a valid date. It is available in the Designer and the Workflow Manager.
     IS_DATE( value )
Example : The following expression checks the INVOICE_DATE port for valid dates:
IS_DATE( INVOICE_DATE )
This expression returns data similar to the following:
INVOICE_DATE
RETURN VALUE
NULL
NULL
180
0 (FALSE)
'04/01/98'
0 (FALSE)
'04/01/1998 00:12:15'
1 (TRUE)
'02/31/1998 12:13:55'
0 (FALSE) (February does not have 31 days)
'John Smith'
0 (FALSE)
This function can also be used to validate a date for a specified format for which the syntax is
IS_DATE( value, format )
If the format is not specified, ‘MM/DD/YYYY’ is taken as the default format.

5.3      IS_NUMBER

The IS_NUMBER returns whether a string is a valid number. It is available in the Designer and the Workflow Manager.
     IS_NUMBER( value )
Example : The following expression checks the ITEM_PRICE port for valid numbers:
IS_NUMBER( ITEM_PRICE )
ITEM_PRICE
RETURN VALUE
123.00
1 (True)
-3.45e+3
1 (True)
''
0 (False) Empty string
+123abc
0 (False)
ABC
0 (False)
-ABC
0 (False)
NULL
NULL

5.4      IS_SPACES

The IS_SPACES function returns whether a value consists entirely of spaces. It is available in the Designer and the Workflow Manager.
     IS_SPACES( value )

Example : The following expression checks the ITEM_NAME port for rows that consist entirely of spaces:
IS_SPACES IS_SPACES ( ITEM_NAME )
ITEM_NAME
RETURN VALUE
Flashlight
0 (False)

1 (True)
Regulator system
0 (False)