Page 1 of 1

how to find ds logic

Posted: Fri Jul 06, 2012 2:23 pm
by RK72
Source File: | Target File:
empno,empname,leadname | empno.empname,leadname,managername
101,John,Dave | 101,John,Dave,Nicholas
102,Dave,Nicholas | 102,Dave,Nicholas,
103,Tony,David | 103,Tony,David,Jennet
104,David,Jennet | 104,David,Jennet,

In the above example Dave is lead of John and Nicholas is lead of Dave so Nicholas is Manager of John. Similarly David is lead of Tony and Jennet is lead of David so Jennet is Manager of Tony.

Use the above logic and create a target file with managername also in target file.

Posted: Fri Jul 06, 2012 2:44 pm
by ankursaxena.2003
Hi,

You will have to do self-join.
The first 3 columns will remain the same and in the third column you will do a lookup and see if there is any lead to the correspoding employee. And if there is then you will append with a comma.

For example,

empno | empname | lead name | manager name
101 | John | Dave | Nicholas(do a lookup on lead name and get it from table)
102 | Dave | Nicholas | (No name is found corresponding to Nicholas. So it will be blank)
103 | Tony | David | Jennet
104 | David | Jennet | (No name is found corresponding to Jennet. So it will be blank)

I hope this should work.

Re: ok. but in which stages are used in this job

Posted: Fri Jul 06, 2012 3:47 pm
by RK72
ok. but in which stages are used in this job

Posted: Sun Jul 08, 2012 4:30 pm
by Kryt0n
Do you have to worry about multiple levels of hierarchy or only ever 2 levels?

If you can stage this to a database, a recursive lookup would be easier (can't remember the formal name of it but in Oracle I believe it is CONNECT BY)

Posted: Sun Jul 08, 2012 6:23 pm
by ray.wurlod
I'd do it all in user-defined SQL using the appropriate stage type to connect to your particular database.

Posted: Mon Jul 09, 2012 7:05 am
by ankursaxena.2003
You need to use Source, destination and LKP.


Source -----> Lookup(Transformer if you are building Server Job) -----> Destination


@Ray/Kryton - I thought that it could be done by query but wasn't sure how. Could you guys please show me the query.

Posted: Mon Jul 09, 2012 4:48 pm
by ray.wurlod
Something like the following query should do it for you:

Code: Select all

select a.empno, a.empname, a.leadname, b.empname
from emps a left outer join emps b on a.leadname = b.empname

Posted: Tue Jul 10, 2012 2:17 pm
by ankursaxena.2003
Thanks.....

Posted: Tue Jul 10, 2012 4:29 pm
by Kryt0n
As long as you only ever need to go two levels deep... which sounds like it may meet your requirement.