Wednesday 13 March 2013

Scenario

1 Q. i have two source, in that send matched rows into one target and unmached rows into another target by using joiner

Ans:JOINER: 
Join Type as - Full Outer Join
Join Condition- M_PK = D_PK (e.g.)


ROUTER:

MATCH GROUP:
Condition M_PK IS NOT NULL AND D_PK IS NOT NULL

DEFAULT: Will have Unmatched records.

2 Q> Source
ID NAME MOBILE
101 RAM 12345
101 RAM 67890
102 RAJ 23456
102 RAJ 78901
103 RACK 34567
103 RACK 89012
104 SAM 45678
104 SAM 90123

Target
ID NAME MOBILE
101 RAM 1234567890
102 RAJ 2345678901
103 RACK 3456789012
104 SAM 4567890123
Ans:

Assuming that the source records do not change the order-

Use an Expression transform:

Port Name | Port Type | Expression
--------------------------------------------
ID ------------ | I/O 
NAME ------ | I/O
MOBILE ---- | I
V_MOB ---- | V ---------- | IIF( V_PREV_ID = ID, V_MOB || MOBILE, MOBILE )
V_PREV_ID | V ---------- | ID
O_MOB -----| O ---------- | V_MOB
O_FLAG --- | O ---------- | CUME(1)


Next use a Filter transform:

Condition: MOD( O_FLAG, 2 ) = 0

Finally the target.

3 Q: Why cant we use dynamic lookup in unconnected lookup ?

Ans: Dynamic lookup feature can never be handled by Unconnected lookup. 

For Dynamic Lookup we need the NewlookupRow column as output, along with all the columns of the lookup which needs to be associated first with the input ports as output to populate the target. We need multiple ports as output that cannot be achieved by Unconnected lookup.

4 Q: how we can add header and footer to the flat file?
ANS:
There are two options available in session properties to take care of this requirement. For this, Go to Mapping Tab Target Properties and Choose the header option as Output Field names OR Use Header Command output File.

Option 1, will create your output file with a header record and the column heading names will be same as your Target transformation port names.

Option 2, we can create our command to generate the header record text. We can use an 'echo' command here to get this created. Here is an example 
echo '"EMPNO"|"DEPTNO"'

It is recommended using the second option as it gives more flexibility for writing the column names. 

For footer in the mapping level, create the footer information like number of records processed, sum of revenue etc. and generate a flat file.

Use post-session command task to append this information of the footer file to the data file.

cat footer.txt >> EMP.txt

No comments:

Post a Comment