GeekInterview.com
Series: Subject: Topic:
Question: 57 of 726

Typical Scenario - Schedule

Please help to set up following scenario

I have a source either file or db table

Eno ename sal dept
101 sri 100 1
102 seeta 200 2
103 lax 300 3
104 ravam 76 1
105 soorp 120 2

Want to run a session 3 times.

First time: it should populate dept 1
Second time: dept 2 only
Third time: dept 3 only

How can we do this?
Asked by: n.sriramk | Member Since Nov-2010 | Asked on: Nov 7th, 2010

View all questions by n.sriramk   View all answers by n.sriramk

Showing Answers 1 - 7 of 7 Answers
d.srinuvasu

Answered On : Nov 7th, 2010

View all answers by d.srinuvasu

You can use a parmeter variable in mapping.

  
Login to rate this answer.
Vijay132

Answered On : Dec 2nd, 2010

View all answers by Vijay132

Use the lookup transformation on target table and apply the look up condition.
otherwise use 
set variable function in an expression transformation or mapping variable.

  
Login to rate this answer.
sudhir24

Answered On : Dec 31st, 2010

View all answers by sudhir24

Use expression, filter and mapping variable.

Set initial value of mapping variable (eg.$$LOAD_DEPT) to 0.
In expression trans, add an output port V_LOAD_DEPT and assign to SETVARIABLE($$LOAD_DEPT,$$LOAD_DEPT+1)
Pass it to filter trans and add filter condition E_DEPT = V_LOAD_DEPT

The variable value is incremented by 1 each time session is run.
Eg. for the first run, the value will be 1, the filter condition matches Dept value 1 and only passes Dept 1 rows. For second run, it will be 2 and only Dept 2 rows will be loaded. (and similarly for future runs).

Yes  3 Users have rated as useful.
  
Login to rate this answer.

Write the following query in to the source qualifier,

select empno, ename, sal, deptno from emp_src
where deptno > (select max(deptno) from emp_trg);

the query returns only the department records from source, which are not yet loaded in to the target.

then you can use the rank(any other approach) transformation to get only the minimum department records. and then load to the target.

Cheers,

Nagaraju Puppala

Yes  2 Users have rated as useful.
  
Login to rate this answer.
vipuldass

Answered On : Jul 11th, 2012

View all answers by vipuldass

would go with sudhir24s answer.
@Nagaraju Puppala: The src query will not work when the mapping is executing for the first time, and there is no data in the tgt.

  
Login to rate this answer.
dileep671

Answered On : Jul 25th, 2012

View all answers by dileep671

Put this query in Source Qualifier

select empno, ename, sal, deptno from emp_src
where deptno not in (select deptno from emp_trg);

Then connect it to Rank Transformation
In the properties, Select Top 1 Row...

From Rank.. connect to target Table.. 1 Row gets inserted every time when the session runs.

Cheers
Dileep

  
Login to rate this answer.
MAHESH MANAM

Answered On : Sep 27th, 2012

We can solve this issue by the following types:

First, we can create a mapping parameter and run the mapping in each time give the parameter value according to your requirement.

Second, we can create a reusable expression and in that create a variable and assign value as 0 and increases by1.It pass to filter make condition on based on variable.If run in second time the value already stored in that variable and increase it by 1.

Third, we can create 3 different mappings and sessions in a single workflow and connect all these into start.Create workflow parameter and assign value based on requirement.

Yes  1 User has rated as useful.
  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.