Job Running Logic

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Re: Advertisement

Post by pravin1581 »

ray.wurlod wrote:Do you seek something like a review of existing work?
No , I was basically looking for any other way of doing it than what we have implemented.Because , right now we have to design a job sequence which comprises 2 jobs, 1 execute command stage and a sequencer.Just wondering whether this design will help in saving the time that was the main objective of the whole exercise.
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Re: Advertisement

Post by pravin1581 »

pravin1581 wrote:
ray.wurlod wrote:Do you seek something like a review of existing work?
No , I was basically looking for any other way of doing it than what we have implemented.Because , right now we have to design a job sequence which comprises 2 jobs, 1 execute command stage and a sequencer.Just wondering whether this design will help in saving the time that was the main objective of the whole exercise.
Hi All,

I think we need to reopen this issue as it is not running the way it was supposed to be.First of all the 'cat ' command is not working properly if any parameter is used in place of file path such as 'cat $file_path/count.txt'. It gives error such as cat cannot open file.txt.
And in the trigger link we are using Return Conditional with expression as 0 for the stop link and 1 for the next job.
It always runs that link which has return value of 0 negelecting the value of the count parameter.
Please suggect how this logic can be implemented.
Thanks in advance.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Please post the current version of your code, along with the results of any diagnostic attempts you may have made (for example capturing the actual command that was sent).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

ray.wurlod wrote:Please post the current version of your code, along with the results of any diagnostic attempts you may have made (for example capturing the actual command that was sent).
The command used in the Exec command stage is as follows

[/code]
COUNT_VALUE=`cat /file_path/hotel_count_file.txt`;echo $COUNT_VALUE

Code: Select all


 Based on the count value the next link should progess, if the Count_Value is 0 then stop job otherwise next link.
 This logic has been implemented using trigger using Return Value (conditional). If expression=0 then stop job and and if =1 then next job.
As return value was processing based on 0 and not on COUNT_VALUE we implemented Custom conditional with expression as 
If COUNT_VALUE>0 Then DSJS.RUNOK Else DSJS.STOPPED for one link and If COUNT_VALUE<0 Then DSJS.RUNOK Else DSJS.STOPPED for the other link

Code: Select all


 But the result remains the same , the logic is not being implemented based on the Count value.
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

pravin1581 wrote:
ray.wurlod wrote:Please post the current version of your code, along with the results of any diagnostic attempts you may have made (for example capturing the actual command that was sent).
The command used in the Exec command stage is as follows

[/code]
COUNT_VALUE=`cat /file_path/hotel_count_file.txt`;echo $COUNT_VALUE

Code: Select all


 Based on the count value the next link should progess, if the Count_Value is 0 then stop job otherwise next link.



 This logic has been implemented using trigger using Return Value (conditional). If expression=0 then stop job and and if =1 then next job.
As return value was processing based on 0 and not on COUNT_VALUE we implemented Custom conditional with expression as 
If COUNT_VALUE>0 Then DSJS.RUNOK Else DSJS.STOPPED for one link and If COUNT_VALUE<0 Then DSJS.RUNOK Else DSJS.STOPPED for the other link

Code: Select all


 But the result remains the same , the logic is not being implemented based on the Count value.


Still waiting for any suggestions.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

After only two hours?!!

Some of us have to work for a living.

We don't do "urgent" here. If you need urgent help, sign up with your support provider for premium service and learn the true cost of urgent.

Put in some diagnostic calls to DSLogInfo() or UtilityMessageToLog(), for example to report the value of the environment variable COUNT_VALUE.

For example, because of the cat command's behaviour, this may have a trailing newline character.

Why are you testing COUNT_VALUE (the name of the environment variable) rather than $COUNT_VALUE (the value of the environment variable) in your trigger expression?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

ray.wurlod wrote:After only two hours?!!

Some of us have to work for a living.

We don't do "urgent" here. If you need urgent help, sign up with your support provider for premium service and learn the true cost of urgent.

Put in some diagnostic calls to DSLogInfo() or UtilityMessageToLog(), for example to report the value of the environment variable COUNT_VALUE.

For example, because of the cat command's behaviour, this may have a trailing newline character.

Why are you testing COUNT_VALUE (the name of the environment variable) rather than $COUNT_VALUE (the value of the environment variable) in your trigger expression?
Apologies for the urgency shown, COUNT_VALUE is the parameter that has been defined in the job, it is not an environmental varaible.It should get its value from the command executed in the Exec Command stage . If we hardcode the file path then the cat command works but when file path is parameterized it is not working. In both the cases the COUNT_VALUE variable is not getting its value.We have even tried using User Variable stage and then Nested Condition stage but the result remain the same.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What is the precise value returned by the UNIX command (including all line terminator characters)?
How are you loading that value into your job parameter? Are you, for example, trimming any line terminator and/or field mark characters?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

ray.wurlod wrote:What is the precise value returned by the UNIX command (including all line terminator characters)?
How are you loading that value into your job parameter? Are you, for example, trimming any line terminator and/or field mark characters?
Ok, let me explain once more. The basic objective is to run the job based on the count of records in the input table, if the count is 0 then stop the job otherwise run the job.

1. We first created a job that fires a select count query on the input table and saves that value in the file.
2. In the next step we used a exec command stage to pass the unix cat command and store the value in the file in a variable.

Code: Select all


     Count=`cat file_name`
In the trigger link of the exec command stage we had two expressions for 2 output link , one for the actual job and other for the stop request using a sequencer.

3. In the trigger link the following expression is used :

Code: Select all


   If COUNT_VALUE.$CommandOutput >0 Then DSJS.RUNOK Else DSJS.STOPPED for the actual job 

  If COUNT_VALUE.$CommandOutput <0 Then DSJS.RUNOK Else DSJS.STOPPED for the sequencer.

The problem is the variable is not getting its value and neither the logic implemented in the trigger link is working.

Is the design ok, or is there a better way to do it.

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

Post by chulett »

3. Those are not 'expressions' - you have assignment statements in your triggers. :?

An expression evaluates to TRUE or FALSE, nothing more, and the value that the expression resolves to determines if the trigger 'fires' (TRUE) or doesn't fire (FALSE). They should simply have the following:

Code: Select all

COUNT_VALUE.$CommandOutput >0
COUNT_VALUE.$CommandOutput <0
And then whatever is on the other end of the trigger link determines what happens next. And either add another trigger to handle =0 or fold that into an existing trigger.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

And even then you may need

Code: Select all

Convert(@FM,"",ActivityName.$CommandOutput)
to get rid of the translated line terminator characters.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

chulett wrote:3. Those are not 'expressions' - you have assignment statements in your triggers. :?

An expression evaluates to TRUE or FALSE, nothing more, and the value that the expression resolves to determines if the trigger 'fires' (TRUE) or doesn't fire (FALSE). They should simply have the following:

Code: Select all

COUNT_VALUE.$CommandOutput >0
COUNT_VALUE.$CommandOutput <0
And then whatever is on the other end of the trigger link determines what happens next. And either add another trigger to handle =0 or fold that into an existing trigger.
In that case the link COUNT_VALUE.$CommandOutput >0 should run when the count is greater than zero but that is not happening.
The message in the job log is :-

Code: Select all


JobControl (@COUNT_VALUE): Executed: COUNT_VALUE=`cat /file_path/hotel_count_file.txt` 
Reply=0
Output from command ====>

pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

ray.wurlod wrote:And even then you may need

Code: Select all

Convert(@FM,"",ActivityName.$CommandOutput)
to get rid of the translated line terminator characters.
Where this command is to be used.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

pravin1581 wrote:In that case the link COUNT_VALUE.$CommandOutput >0 should run when the count is greater than zero but that is not happening.
The message in the job log is :-

Code: Select all

JobControl (@COUNT_VALUE): Executed: COUNT_VALUE=`cat /file_path/hotel_count_file.txt` 
Reply=0
Output from command ====>

:? What you should be executing is just the cat statement, no assignment (again) and no back-ticks:

Code: Select all

cat /file_path/hotel_count_file.txt
That will cause your count to be echo'd to the screen and picked up by the Sequence in the $CommandOutput variable. And then Ray's advice comes into play in your trigger:

Code: Select all

Convert(@FM,"",COUNT_VALUE.$CommandOutput) >0
Or perhaps more simply:

Code: Select all

COUNT_VALUE.$CommandOutput<1> >0
-craig

"You can never have too many knives" -- Logan Nine Fingers
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

chulett wrote:
pravin1581 wrote:In that case the link COUNT_VALUE.$CommandOutput >0 should run when the count is greater than zero but that is not happening.
The message in the job log is :-

Code: Select all

JobControl (@COUNT_VALUE): Executed: COUNT_VALUE=`cat /file_path/hotel_count_file.txt` 
Reply=0
Output from command ====>

:? What you should be executing is just the cat statement, no assignment (again) and no back-ticks:

Code: Select all

cat /file_path/hotel_count_file.txt
That will cause your count to be echo'd to the screen and picked up by the Sequence in the $CommandOutput variable. And then Ray's advice comes into play in your trigger:

Code: Select all

Convert(@FM,"",COUNT_VALUE.$CommandOutput) >0
Or perhaps more simply:

Code: Select all

COUNT_VALUE.$CommandOutput<1> >0
Thanks for the reply, then should I not use the variable COUNT_VALUE and neither should I assign it the value generated by the cat command. The Exec command should call the cat command only.
Then why should i use COUNT_VALUE.$CommandOutput if I am not supposed to use the COUNT_VALUE variable.I that variable is not declared then I wouldn't get it and what is the convert command doing.
Post Reply