looping

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
fish
Premium Member
Premium Member
Posts: 3
Joined: Thu Sep 18, 2008 6:48 am

looping

Post by fish »

Being in the process of learning datastage, I have a question and will start here with it. I have a sequence job that then calls a server job. I would like to use a loop with the sequence and would like to pass the loop counter down to the server job and used as a variable in a transformer, but I am not sure how to do that as the documentation is not clear, being a newbie at this I hope someone here can explain this process in a bit more detail. The looping only seems to be available at the seq level. Any help with this would be greatly appreciated.
Thanks, Chris
ag_ram
Premium Member
Premium Member
Posts: 524
Joined: Wed Feb 28, 2007 3:51 am

Post by ag_ram »

One can pass a value to job using by job paramter. And you cant assign a new value to a job paramter at sequence level.
I have tried some time back and this is not possible to send loop counter to job. But you can manage the loop counter at sequence level using user variable activity stage.

thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sure, you can send the current loop counter as a job parameter to an activity inside the loop. Use the name of your Start Loop stage followed by ".$Counter" as the value. Note this is directly accessable from the "External Parameter Helper" / "Insert Parameter Value" picker widget from any stage downstream of the Start Loop.
-craig

"You can never have too many knives" -- Logan Nine Fingers
fish
Premium Member
Premium Member
Posts: 3
Joined: Thu Sep 18, 2008 6:48 am

loop

Post by fish »

chulett wrote:Sure, you can send the current loop counter as a job parameter to an activity inside the loop. Use the name of your Start Loop stage followed by ".$Counter" as the value. Note this is directly accessable from the "External Parameter Helper" / "Insert Parameter Value" picker widget from any stage downstream of the Start Loop.
Maybe I have misunderstood. If I have a sequence job that calls a server job from within the "job activity" in that sequence job, and I want to pass the counter between those two so it can be used within a transformer in the server job. I am not seeing where in the parameters I can pass that, so I must be missing something. I find a job properties that has a parameter tab for the entire job for both the sequence and the server jobs, that I can get to from the tool bar and I find a parameter list window that comes up when I open the "job activity" icon in the sequence job, but they don't seem to be connected, what am I missing here.
thanks again
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You don't need to create a parameter in the Sequence job itself for this, however the Server job will of course need one. The Job Activity stage will show all of the parameters associated with the job to run and allow you pass values from the Sequence job to the Server job, be that parameters or values of any type generated within the Sequence.

Not sure what you mean by "not connected". If you leave the Parameter's "Value Expression" empty then the job will use whatever default value it has for that parameter when it runs. Or you can pass in any other valid value - hard-coded, generated by a previous activity, passed in as a job parameter in the Sequence itself, etc - to the job for that parameter to use when the job runs. And that "Value Expression" was where I assumed you need to pass the current loop counter to the job the Job Activity stage inside the loop was running.

Does any of that help?
-craig

"You can never have too many knives" -- Logan Nine Fingers
fish
Premium Member
Premium Member
Posts: 3
Joined: Thu Sep 18, 2008 6:48 am

re:looping

Post by fish »

chulett wrote:You don't need to create a parameter in the Sequence job itself for this, however the Server job will of course need one. The Job Activity stage will show all of the parameters associated with the job to run and allow you pass values from the Sequence job to the Server job, be that parameters or values of any type generated within the Sequence.

Not sure what you mean by "not connected". If you leave the Parameter's "Value Expression" empty then the job will use whatever default value it has for that parameter when it runs. Or you can pass in any other valid value - hard-coded, generated by a previous activity, passed in as a job parameter in the Sequence itself, etc - to the job for that parameter to use when the job runs. And that "Value Expression" was where I assumed you need to pass the current loop counter to the job the Job Activity stage inside the loop was running.

Does any of that help?
Okay, after carefully reading your answer and looking at this, I think I got it working, at least it saved, compiled and ran. Now I have to verify the results. I greatly appreciated your help.
Thanks again, Chris
Chris Davidson
Senior Programmer/Analyst
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Well, let us know if anything is still unclear or not working as expected. It can be hard to really understand what someone is having a problem with when you're not looking over their shoulder. :wink:

ps. You don't need to quote everything you are replying to, there is a "Reply to Topic" button so you can do just that without all of the extra clutter that "Reply with Quote" creates. I only use that when I need to quote so people understand which post (or portion of post) I am replying to when there could be ambiguity.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply