To run a job based on the output of the first job

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

Moderators: chulett, rschirm, roy

adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

To run a job based on the output of the first job

Post by adityavarma »

Hi,

I have an requirement where in i need to run the job2 based on the output value of the column of the job1.

Job1 --> Job 2


Can anyone please help me on this.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Could you specify the problem a bit more, since generally a job processes more than one record, and thus each column can have many values.
Generally you could make a constraint in a transform stage which either creates a text file with the value you want, or could set the user status to that value, which a sequence can pick up and pass to the second job.
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

Post by adityavarma »

In my first job i have source as oracle table i need to execute a sql query to find out the value of the column in that table, that value will be success or aborted, if the value is aborted the next job should not start and if the value is success then the next job should be initiated.

Regards,
Aditya
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You can write a job sequence which only executes job 2 if job 1 finishes successfully. In your example, Job 1 would abort and thus Job 2 will not run; so you don't need to know the value of any columns.
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

Post by adityavarma »

In my case, the job 1 will always be successfull.
In the job1 i am writing a column into a dataset file
i am fetching the column1 value from the oracle table.

Column1
======
Success or aborted.

If the column1 value is "aborted" then the main sequence should abort. if the column1 value is "success" then the job2 should start.

MAin seq

job1 --> job2
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Write it to something simple, a flat file for instance. Then an Execute Command stage can 'cat/read' the value and your triggers can decide to run Job2 or not based on the result.
-craig

"You can never have too many knives" -- Logan Nine Fingers
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

Post by adityavarma »

Hi Chulett/Andrw

Thanks for the reply,

Now i got how to proceed on this,
but i am stuck in the execute command triggers to start or abort the job.

If Trim(Execute_Command_22.$CommandOutput) = 'SUCCESS' Then Else

I am unable to get which command to use to start the next job if the output is success and to abort the job if the status is aborted.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Success trigger could be just Trim(Execute_Command_22.$CommandOutput) = 'SUCCESS' while for the abort an 'Otherwise' trigger would work.
-craig

"You can never have too many knives" -- Logan Nine Fingers
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

Post by adityavarma »

Craig,

I have kept the below code but still the job2 is not been triggered
Trim(Exec_column.$CommandOutput) = "SUCCESS"

then i have link to the job2 and otehr wise link to the terminator activity

The job1 is finished succesfully but the job2 is not ben initiated.


JOb1 --> executecmd --> job2
|
V
terminator activity
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Confirm for us the command you are executing. That and try this as the success trigger: Execute_Command_22.$CommandOutput<1>) = "SUCCESS"
-craig

"You can never have too many knives" -- Logan Nine Fingers
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

Post by adityavarma »

The Command i am executing in the execute command acitivity is
Command: cat
Parameters: <filename>
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

Can you check the output for the command you executed from director log .
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That's what I assumed, the trigger I gave you should work as it "removes" the Field Mark that is in the output. You could also use EReplace() for that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

Post by adityavarma »

I am not able to find any output in the director log for the execute command activity.

i have used Exec_DAILY_SALES_BATCH_STATUS.$CommandOutput <1>= "SUCCESS"

But still the next job is not been intiated.
Last edited by adityavarma on Thu Oct 14, 2010 12:44 am, edited 1 time in total.
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

Post by adityavarma »

Sorry , My mistake and it is a very silly one

I have kept the trigger as
job_name.$JobStatus=2 Or job_name_Load.$JobStatus =3 and have send the link to execute command acitivity for which the trigger only will execute the command activity only if the job1 is aborted,but the job is running successfully, so the execute command acitivity is not been triggered.

I have executed the below triggers

Exec_DAILY_SALES_BATCH_STATUS.$CommandOutput<1>="SUCCESS"

Trim(Exec_DAILY_SALES_BATCH_STATUS.$CommandOutput)<1>= "SUCCESS"

Trim(Ereplace(Exec_DAILY_SALES_BATCH_STATUS.$CommandOutput,"'","") )


For all the above triggers the

Reply=0
Output from command ====>
"SUCCESS"

but still the main sequence is aborting.


I have found out one more issue, i have created a parameter set for all the jobs , but i am unable to find the parameters in the execute command acitivity.


Regards,
Aditya
Post Reply