Beruflich Dokumente
Kultur Dokumente
Scenario1:
We have a source table containing 3 columns : Col1, Col2 and Col3. There is only 1 row in the table as follows:
Col1
Col2
Col3
There is target table containg only 1 column Col. Design a mapping so that the target table contains 3 rows as
follows:
Col
a
b
c
Without using normaliser transformation.
Solution:
Create 3 expression transformations exp_1,exp_2 and exp_3 with 1 port each. Connect col1 from Source Qualifier to
port in exp_1.Connect col2 from Source Qualifier to port in exp_2.Connect col3 from source qualifier to port in exp_3.
Make 3 instances of the target. Connect port from exp_1 to target_1. Connect port from exp_2 to target_2 and
connect port from exp_3 to target_3.
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.
COL1
COL2
COL3
COL2
COL3
COL1
COL2
COL3
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
qualifier
to
two
rank
In Rank2
Header
col2
data2
data6
data2
data2
col3
data3
data7
data3
data3
here
col4
data4
data8
data4
data4
and
scheduled
it.
Step4:Chose the advance option. Set number of initial rows skip: 1 ( it can be more as per requirement )
ADV PROPERTIES
Drag
and
drop
the
source
2.
to
mapping.
3.
Then connect to target.Now you are ready to run the mapping to see it in action.
Step:3 Then connect to target, and run mapping to see the results.
Scenario
9:
How
to
send
alternate
record
Or
Sending Odd numbered records to one target and even numbered records to another target.
to
target?
Solution:
Step
Step2:
1:
Add
Drag
the
source
the next value of a
and
connect
to
sequence generator to
an
expression
transformation.
expression transformation.
Step 3: In expression transformation make two port, one is "odd" and another
"even".
And Write the expression like below
EXPRESSION PROPERTY
RTR PROPERTY
Scenario 10: How to separate the original records from source table to separate target table by using rank
transformation ?
Source Table
col1
col2
col3
Target Table
Col1
Col2
Col3
Solution:
Step 1: Bring the source to mapping.
RANK PROPERTY
Scenario 11: In Dept table there are four departments (dept no 40,30,20,10). Separate the record to different target
department wise.
Solution:
Step 1: Drag the source to mapping.
Step 2: Connect the router transformation to source and in router make 4 groups and give condition like below.
ROUTER TRANSFORMATION
ROUTER TO TARGET
2.
Arrange the salary in descending order in sorter as follows and send the record to expression.
3.
Add the next value of sequence generator to expression.(start the value from 1 in sequence generator).
4.
Connect the expression transformation to a filter or router. In the property set the condition as follows-
5.
Put
the
source
to
mapping
and
connect
the
ports
to
aggregator
transformation.
2.
Make 4 output ports in aggregator as in the picture above : count_d10, count_d20, count_d30, count_d40.
For
3.
each
Then
port
send
write
expression
it
like
to
in
the
expression
picture
below.
transformation.
4.
In expression make four output ports (dept10, dept20, dept30, dept40) to validate dept no
And
5.
Then
provide
connect
the
to
router
expression
transformation.
like
And
create
in
group
the
and
picture
fill
condition
below.
like
below.
6.
Finally
connect
to
target
table
having
one
column
that
is
dept
no.
Connect
Add
the
an
next
expression
value
port
of
transformation
sequence
generator
after
to
source
expression
qualifier.
transformation.
2.
In expression create a new port (validate) and write the expression like in the picture below.
3.
Connect a filter transformation to expression and write the condition in property like in the picture below.
4.
Finally
connect
to
target.
Drag the source and connect to an expression.Connect the next value port of sequence generator to
expression.
2.
Send the all ports to a router and make three groups as bellow
Group1
mod(NEXTVAL,30) >= 1 and mod(NEXTVAL,30) <= 10
Group2
mod(NEXTVAL,30) >= 11 and mod(NEXTVAL,30) <= 20
Group3
mod(NEXTVAL,30) >= 21and mod(NEXTVAL,30) <= 29 or mod(NEXTVAL,30) = 0
3.
Finally
connect
Group1
to
T1,
Group2
to
T2
and
Group3
to
T3.
< Prev
Next >
Col2
b
col1
n
col2
x,m
y,n
Target Table: T2
Solution:
1.
We
have
to
use
the
following
transformation
as
below.
First connect a sorter transformation to source and make col1 as key and its order is ascending. After that
connect
it
to
an
expression
transformation.
2.
In
Expression
3.
In
concat_val
make
write
four
new
expression
like
port
as
and
give
describe
them
bellow
name
and
as
send
in
it
to
picture
an
below.
aggregator
4.
In
aggregator
5.
group
it
by
col1
and
send
it
to
target
SOURCE TABLE
id
Sal
200
300
500
560
TARGET TABLE
Id
Sal
200
500
1000
1560
1.
Pull
2.
In
the
expression
source
add
one
to
mapping
column
and
and
make
then
it
connect
output(sal1)
and
it
sal
to
port
as
expression.
input
only.
We will make use of a function named cume() to solve our problem, rather using any complex mapping. Write
the
expression
in
sal1
as
cume(sal)
and
send
the
output
rows
to
target.
Drag your target file to target designer and add a column as show on the picture. Its not a normal column
.click
2.
on
the
add
file
name
to
the
table
property.
(I
have
given
red
mark
there)
Then drag your source to mapping area and connect it to an expression transformation.
3.
In expression transformation add a new port as string data type and make it output port.
4.
In that output port write the condition like describe as bellow and then map it in to filename port of target.
Also send other ports to target. Finally run the session. You will find two file one with sys date and other one is
.out file which one you can delete.
5.
2.
In Query Editor, choose folder name and object type as I have shown in the picture.
3.
4.
Query results window will appear. You select single mapping (by selecting single one) or
whole mapping (by pressing Ctrl + A) and go to "tools" then "validate" option to validate it.
< Prev
Next >
0 Comments.
Tell us what do you think
Go to mapping then parameter and variable tab in the Informatica designer.Give name as $$v1, type choose
parameter (You can also choose variable), data type as integer and give initial value as 20.
2.
Create a mapping as shown in the figure( I have considered a simple scenario where a particular
department
id
will
be
filtered
to
the
target).
3.
In
filter
set
deptno=$$v1
(that
means
only
dept
no
20
record
will
go
to
the
4.
Mapping parameter value cant change throughout the session but variable can be changed. We can
change variable value by using text file. Ill show it in next scenario.
target.)
1.
Drag the source to mapping area and connect each port to an expression transformation.
2.
In expression transformation add a new col sal1 and make it as out put and sal as in put only as shown in
picture.
3.
4.
First thing we should consider that there are different types of currency like pound, dollar, yen etc.So its a
good idea to use mapping parameter or variable.Go to mapping=> mapping parameter and variables then
create three parameters (for this example) and set its initial value as bellow
2.
Then drag the source to mapping area and connect to an expression transformation.
3.
In expression create a output port as sal1 and make sal as input only as bellow.
4.
$$DOLAR,$$POUND,$$YEN these are mapping parameter . you can multiply price in rupee directly for
example dollar price in rupees i.e 48 .
5.
Connect required output port from expression to target directly. And run the session.
2.
Drag an sequence generator transformation and set properties like this And connect the next value port to
expression.
3.
Drag all output port of expression to router. In router make three groups and gve the conditions Like
this
4.
CLERK
SALESMAN
7902 17-DEC-80
7698 20-FEB-81
$800
20
$1600
30
Target
EMPNO ENAME
JOB
MGR HIREDATE
SAL
7369 SMITH
CLERK
7902 17-DEC-80
Rs.800
7499 ALLEN
SALESMAN
7698 20-FEB-81
RS.1600
DEPTNO
20
30
1.
2.
In expression make a output port sal1 and make sal as input port only.
3.
4.
2.
3.
If you have any better way to solve this, don't forget to comment
1.
1.
2.
In Expression add 6 columns like in the picture as bellow. But You can make it two columns( One for all the
vowels and one for the vowel counts). For better understanding I have added 6 columns,5 for each of the
vowels
and
one
for
the
vowel
count.
The way I achieved is for each of the vowels in ename , I replaced it with null and in port total vowel count , I
substract the vowel port from the ename length which gives me the individual count of vowels, after adding up
for
all
vowels
For
For
For
For
found
all
A
E
the
write
write
I
present.
Here
are
all
the
variable
ports.
REPLACECHR(0,ENAME,'a',NULL)
REPLACECHR(0,ENAME,'e',NULL)
write
O
vowels
REPLACECHR(0,ENAME,'i',NULL)
write
REPLACECHR(0,ENAME,'o',NULL)
For
And
for
o/p
write
column
REPLACECHR(0,ENAME,'u',NULL)
total_vowels_count
write
expression
like
(length(ENAME)-length(A))
+
(length(ENAME)-length(E))
+
(length(ENAME)-length(I))
+
(length(ENAME)-length(O))
+
(length(ENAME)-length(U))
3.
this
In target
empno
7321
4321
3242
Following are the steps for achieving this mapping
1.
2.
In expression make empno as input and create another port empno1 as output port with date datatype. And
in empno1 write condition like this. and finally send it to target
28.
Senario:Suppose you are importing a flat file emp.csv and hire_date colummn is in numeric format, like 20101111
.Our objective is convert it to date,with a format 'YYYYMMDD'.
source
EMPNO
------1
2
target
EMPNO
------
HIRE_DATE(numeric)
----------20101111
20090909
HIRE_DATE (date)
-----------
1
2
11/11/2010
09/09/2009
1.
2.
In expression make hire_date as input only and make another port hire_date1 as o/p port with date data
type.
3.
4.
29.
1.
2.
In expression create another oupput port hire_date1 and make it to date data-type, shown in picture.
3.
4.
30.
We have to calculate difference between order_date and delivery date in hours and send it to target.
o/p will be
ORDER_NO ORDER_DATE DELIVERY_ DATE
DIFF_IN_HH
--------------------------------2
11-JAN-83
13-JAN-83
48
3
04-FEB-83
07-FEB-83
72
1
08-DEC-81
09-DEC-81
24
These are the steps for achieving this scenario
Don't forget to comment
1.
2.
In expression create one out/put port diff and make it integer type.
3.
In that port write the condition like this and sent to target.
31.
Sending to target with days difference more than 2
days
Scenario: From the order_delivery table insert the records to target where , day difference between order_date
and delivery_date is greater than 2 days. ( Note: see last article , where we discussed finding the time in hour
between two dates)
Source
ORDER_NO ORDER_DATE
DELIVERY_DATE
------------------------2
11-JAN-83
13-JAN-83
3
04-FEB-83
07-FEB-83
1
08-DEC-81
09-DEC-81
Target
ORDER_NO ORDER_DATE DELIVERY_ DATE
---------------- ------ --- ---------2
11-JAN-83
13-JAN-83
3
04-FEB-83
07-FEB-83
These are the steps for achieving this scenario
1.
2.
3.
32
Convert Day No. to corresponding month and
date of year
Scenario: Suppose you have a source is like this
Source
E_NO YEAR
DAYNO
------ --------- --------1
01-JAN-07 301
2
01-JAN-08 200
Year column is a date and dayno is numeric that represents a day ( as in 365 for 31-Dec-Year). Convert the Dayno
to corresponding year's month and date and then send to targer.
Target
E_NO
YEAR_MONTH_DAY
-------------- ---------1
29-OCT-07
2
19-JUL-08
These are the basic steps for this scenario
1.
2.
In expression create one o/p port c_year_mm_dd, make it to date type and in that port write the condition
like this.
3.
1.
2.
3.
Amit Rao
Chitra Dash
In target we have to separate ename column to firstnane and lastname like this
empno
firstname
Lastname
Amit
Rao
Chitra
Dash
1.
Drag the source to mapping area and connect with an expression trans formation as shown bellow.
2.
In expression transformation create two output port one is f_name and other is l_name.
3.
4.
ename
ename
Sekher
Prasad
2.
In Expression create two ports one is name1(as variable port) and Middle_Name (o/p port)
3.
4.
5.
SCD TYPE1
SCD TYPE1 MAPPING
The SCD Type 1 methodology overwrites old data with new data, and therefore does no need to track historical data .
1.
2.
3.
4.
Connect lookup to source. In Lookup fetch the data from target table and send only CUSTOMER_ID port
from source to lookup
5.
6.
Then rest of the columns from source send to one router transformation
7.
8.
For new records we have to generate new customer_id. For that take a sequence generator and connect
the next column to expression .New_rec group from router connect to target1(Bring two instances of target to
mapping, one for new rec and other for old rec) .Then connect next_val from expression to customer_id column
of target
9.
Change_rec group of router bring to one update strategy. and give the condition like this
10.
SCD Type2
In Type 2 Slowly Changing Dimension, if one new record is added to the existing table with a new
information then both the original and the new record will be presented having new records with its own
primary key.
1.
2.
3.
4.
All the procedure same as described in SCD TYPE1 mapping. The Only difference is , From router new_rec
will come to one update_strategy and condition will be given dd_insert and one new_pm and version_no will be
added before sending to target.
5.
Old_rec also will come to update_strategy condition will given dd_insert then will send to target.
SCD Type3
In SCD Type3 ,there should be added two column to identifying a single attribute. It stores one time
historical data with current data
1.
2.
3.
Up to rouer transformation ,all the procedure is same as described in Scenario_36 SCD type1.
4.
The only difference is after router bring the new_rec to router and give condition dd_insert send to target.
Create one new primary key send to target.
5.
For old_rec send to update_strategy and set condition dd_insert and send to target.
6.
Unit Testing
Unit Testing
In unit testing what we need do is something like below
1.
2.
In this stage we generally customized sql queries to check source and target.
Analyze the rejected rows and build the process to handle this rejection.
3.
We should look at lesion log and workflow log to view the load statistics
4.
Testing performance
-
Source performance
Target performance
Session performance
Network performance
Database performance
ACTU
FUNCTIONALI
TY_ID
FIELD_NAME
DETAIL
VALUE
EXPECTE
AL
PASS/FAIL
PASSED
D RESULT
RESU
RESULT
REMARK
LT
_TYPE_ID
SHOULD BE NOT
NULL ,FIRST
CHARACHER
STG_SCHM_D
TLS_001
LOAN
_ID
ALPHABET(INSCH
) AND LAST 10
CHARACTER
RECO
INSCH0000
ACCEPT
RD
0000002
RECORD
ACCE
PASS
PTED
NUMERIC
VALUES AND
ALSO ITS
LENGTH IS 16
RECORD
REJECT WHEN ,
INSERTED
INTO
5 CHARACHER
REJECTED
REJECT
NOT (INSCH) OR
STG_SCHM_D
LOAN_TYPE_I
LAST 10
INSCP0010
TLS_002
CHARACTER NON
00000002
NUMERIC
FILE WITH
RECORDR
ECORD
PASS
REJECTE
ERROR_ID
&ERROR_
VALUES AND
AN
DETAILS
ALSO ITS
INTO
LENGTH <>16
ERROR_T
ABLE
LOAN_COMPANY
_ID MUST BE
NOT NULL,FIRST
4 CHRACTER
STG_SCHM_D
LOAN_COMPA
TLS_003
NY_ID
ALPHABET(INCO)
AND LAST 11
CHRACTER
RECO
INCO00000
ACCEPT
RD
000003
RECORD
ACCE
PASS
PTED
NUMERIC
VALUES AND
ALSO LENGTH IS
15
RECORD
REJECT WHEN ,
INSERTED
INTO
4 CHARACHER
REJECTED
NOT (INCO) OR
RECO
STG_SCHM_D
LOAN_COMPA
LAST 11
INSO00000
REJECT
RD
TLS_004
NY_ID
CHARACTER NON
060003
RECORD
REJE
NUMERIC
FILE WITH
PASS
CTED
AN
ERROR_ID
&ERROR_
VALUES AND
DETAILS
ALSO ITS
INTO
LENGTH <>15
ERROR_T
ABLE
STG_SCHM_D
TLS_005
RECO
START DATE
START_DATE
SHOULD BE A
12/9/1988
VALID DATE
ACCEPT
RD
RECORD
ACCE
PASS
PTED
RECORD
INSERTED
INTO
REJECTED
START DATE
STG_SCHM_D
RECO
SHOULD NOT BE
START_DATE
LOADED WHEN IT
33FeB/88
REJECT
RD
FILE WITH
PASS
AN