User variable Activity and loop activity question

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
jagadam
Premium Member
Premium Member
Posts: 107
Joined: Wed Jul 01, 2009 4:55 pm
Location: Phili

User variable Activity and loop activity question

Post by jagadam »

Hi,

I need to loop the datastage job by passing the values from a text file which is delimited by comma to the where clause in a user defined SQL having two parameters.

Sample file :

JOHN,US
APPLE,UK
ADAM,INDIA

Sample Query:

select A,B from table
where NAME='#jpparm1'
and COUNTY_CD='#jpparm2'

In first run the job should pull the data where NAME='JOHN' and COUNTY_CD='US' and in second run it should pull where NAME='APPLE' and COUNTY_CD='UK'

Previously i've implemented with only one parameter by using execute command stage to read the data from a file and using convert function and then using the loop activity stage.

Could anyone please throw your inputs in achieving this requirement.
NJ
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

Doesn't sound like the solution is any different, just split the two values before passing to the job
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You might find this post helpful.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

Naveen, i am not sure about your exact requirements. But your sample seems to be little simple and but the solution is time consuming. I mean the job has to run once to fetch just 1 record & keep on running until the loop ends.... PX job takes some time to initialize and then kicks off the data processing.

If you are sure that you will have less than 1000 rows in your input file, then you can do something like this.

Step 1: Concatenate each row in the input file to look like this.

('JOHN~US','APPLE~UK','ADAM~INDIA',...............')

Step 2: Change your SQL as follows.

select A,B from table
where NAME||'~'||COUNTRY_CD IN (output from step 1);

In this case, the job will run only once and the much more faster than the loop process.
Kandy
_________________
Try and Try again…You will succeed atlast!!
Post Reply