Looping in DataStage
Moderators: chulett, rschirm, roy
Looping in DataStage
Hi All,
I have to develop a datastage job which internally calling a web service and updating saleforce.com portal and returning indicator as True or False.
Based on this indicator we have to run the job in loop.
Means if web service return indicator as "False" then againg same job we have to run. Once web service return indicator as "True" means all the records got updated successfully and job should come out of loop and stop the job.
My approach is run the job and store the return of web service in a text file and the using execute command stage read the file and if it retun "False" run the job again. But I am not able to implement this requirement using Start loop and end loop stage.
Please help me if some has any idea or approach to implement this logic.
Thanks in advance.
Santosh
I have to develop a datastage job which internally calling a web service and updating saleforce.com portal and returning indicator as True or False.
Based on this indicator we have to run the job in loop.
Means if web service return indicator as "False" then againg same job we have to run. Once web service return indicator as "True" means all the records got updated successfully and job should come out of loop and stop the job.
My approach is run the job and store the return of web service in a text file and the using execute command stage read the file and if it retun "False" run the job again. But I am not able to implement this requirement using Start loop and end loop stage.
Please help me if some has any idea or approach to implement this logic.
Thanks in advance.
Santosh
Re: Looping in DataStage
Hi Santosh,
If i were you, i would have implemented this logic using a basic routine for the looping logic instead of opting for a sequence job.
In the sequence job we can specify the count of loops to be executed or for an 'in list' for the counter. But i dont think we have the option to break from the loop based on custom condition.
Good luck.
If i were you, i would have implemented this logic using a basic routine for the looping logic instead of opting for a sequence job.
In the sequence job we can specify the count of loops to be executed or for an 'in list' for the counter. But i dont think we have the option to break from the loop based on custom condition.
Good luck.
Re: Looping in DataStage
Hi,Pagadrai wrote:Hi Santosh,
If i were you, i would have implemented this logic using a basic routine for the looping logic instead of opting for a sequence job.
In the sequence job we can specify the count of loops to be executed or for an 'in list' for the counter. But i dont think we have the option to break from the loop based on custom condition.
Good luck.
Thanks. Same thing I was also thinking.
But I am not verymuch comfortable with the routine writing.
Could you provide some small tips how to write routine in DataStage for this particular requirement?
Thanks a lot.
chulett wrote:'Breaking from the loop' is easily done - it's just a matter of branching out of the loop to a point after the End Loop stage based on your 'custom condition'. ...
Hi Craig,
But I did not understand how to do it using sequencer job...because when I am using start loop activity stage there are two types of loop.
In this case we cant use numeric loop because we dont know how many time we have to run the loop.
The second one is List loop there if I pass run it for "false " its running only once. We need to run this job jon in loop untill we get "true".
chulett wrote:To help with this and to cut down on the 'loop speed' add an Execute Command (or Routine Activity) stage inside the loop that does a 'sleep' for a user-configurable period of time. ...
Hi Craig,
I am facing one problem. I am reading the return value from a seq file using execute command and in trigger I am using custom that if return is "false" then job should enter to loop, but its not going to the loop.
But when I put unconditional trigger, job is entering to the loop.
My job design is something like this->
1) Server Job - Calling the web service and storing return to Seq file.--This job is working fine and I am able to get returin seq file.
2) Main Sequence job-
Job Activity stage (calling the server job)-->execute command stage(reading the seq file for true/false, and in Trigger(custom) check the return of the execute command stage and if false go to loop and again call the server job )-->start loop(for 10 times only for testing purpose)--->serverjob---> end loop activity.
But job is getting executed for only one time even though web service returns as false. If I remove the custom trigger, job is entering into the the loop and executing for 10 time.
Please help me if any body has any idea how to implement this.
Thanks
Santosh
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
I believe you are using cat command to get True/False. Are you removing FIELD MARKS before comparision. I think its related to wrong comparision in custom trigger not the logic.
Match case too.
Code: Select all
use $returnvalue<1>="true".
Match case too.
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.
Genius may have its limitations, but stupidity is not thus handicapped.
Hi Kunal,priyadarshikunal wrote:I believe you are using cat command to get True/False. Are you removing FIELD MARKS before comparision. I think its related to wrong comparision in custom trigger not the logic.
Code: Select all
use $returnvalue<1>="true".
Match case too.
I am using following syntax Execute_Command_3.$CommandOutput<1>="true" in custom trigger where Execute_Command_3 is execute command stage but its not working.
Please let me know if I am using the wrong syntax.
Thanks
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
First try to get what is the command output from the sequence log.
are you getting "true"?
Please let us know the command output from the logs.
Then try following codes 1 by 1
And then let us know which one worked (if any).
are you getting "true"?
Please let us know the command output from the logs.
Then try following codes 1 by 1
Code: Select all
Convert(@FM,'',Execute_Command_3.$CommandOutput)="true"
Trim(Convert(@FM,'',Execute_Command_3.$CommandOutput))="true"
UpCase(Trim(Convert(@FM,'',Execute_Command_3.$CommandOutput)))="TRUE"
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.
Genius may have its limitations, but stupidity is not thus handicapped.
priyadarshikunal wrote:First try to get what is the command output from the sequence log.
are you getting "true"?
Please let us know the command output from the logs.
Then try following codes 1 by 1
And then let us know which one worked (if any).Code: Select all
Convert(@FM,'',Execute_Command_3.$CommandOutput)="true" Trim(Convert(@FM,'',Execute_Command_3.$CommandOutput))="true" UpCase(Trim(Convert(@FM,'',Execute_Command_3.$CommandOutput)))="TRUE"
Hi Kunal,
Following are the output of Command output
Mainseq..JobControl (@Execute_Command_3): Executed: cat /Data/Project/input/echo_tg.txt
Reply=0
Output from command ====>
"true"
and I used all three options mentioned by you but its not working for me.
Thanks
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
yes it won't work because you are comparing
"true"=true
here quotes are making the difference
Use one of the codes below
And let us know if it works.
"true"=true
here quotes are making the difference
Use one of the codes below
Code: Select all
Trim(Convert('"','',Convert(@FM,'',Execute_Command_3.$CommandOutput)))="true"
Trim(Convert(@FM,'',Execute_Command_3.$CommandOutput),'"',"A"))="true"
Convert(@FM,'',Execute_Command_3.$CommandOutput)='"true"'
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.
Genius may have its limitations, but stupidity is not thus handicapped.