Help Regarding Loop Variables inside a Sequence Job

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
ArunsundarIndira
Participant
Posts: 3
Joined: Mon Oct 22, 2012 2:12 am
Location: Chennai

Help Regarding Loop Variables inside a Sequence Job

Post by ArunsundarIndira »

Hi All,

I have a issue in getting all the values of the a single parameter ( which is a file name that is dynamically generated while looping) used inside a loop at the end of the loop in a variable.

For e.g.

Loop 1 : var1 = 'file1.sql'
Loop 2 : var1 = 'abc.sql'
Loop 3 : var1 = 'xyz.sql'

I want a variable to hold all the values of variable var1 out of the loop.

Thanks in Advance,
Arun.
Knowledge is Wealth.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

A Variable holding "file1.sql,abc.sql,xyz.sql" outside the loop, then use a comma for the loop separator.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

oops, I see you want it the other way around. Put a user variable activity and generate "BigString" as "BigString:',':$Loop.Loopvariable"
bhasds
Participant
Posts: 79
Joined: Thu May 27, 2010 1:49 am

Post by bhasds »

Hi Arun,

If you are getting the values of a single parameter from a file then using list loop can help you.

1. Cat the file with execute command|xargs|tr -d '\n'
Eg- Output will be file1.sql abc.sql xyz.sql
2.Pass the command output to the loop using list loop.
3.Get the execute command output in a user variable activity once the loop is finished through a activity variable.

Please correct me if I am wrong.
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

Arndw: Will you not need 2 user variables ?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

No two user variables are needed. Just one outside the loop to hold the string containing the loop elements, then the loop counter itself will hold each value for each iteration.
Post Reply