Excuting Job Conditionally

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Vishal1982
Participant
Posts: 38
Joined: Wed Oct 01, 2008 10:30 am

Excuting Job Conditionally

Post by Vishal1982 »

Hi All,

I have two jobs say Job1 and Job2,and I want to Execute these jobs conditionally depending upon the rowcount of a table(Table1), which is stored separately in database and not used in either of Job1 and Job2.

For Example: If my Table1 contains zero records i.e. rowcount=0 ,then i want to execute Job1 and then Job2 and if my Table1 contains more than one record i.e rowcount >1 then want to execute Job2 directly without executing Job1.

Please help me to solve this problem.

Thanks,
Vishal J.
IBM Websphere Datastage Certified Professional
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Several ways.

Simplest will be to run the sql command from command activity and decide on the return value.
Vishal1982
Participant
Posts: 38
Joined: Wed Oct 01, 2008 10:30 am

Post by Vishal1982 »

Hi,

I am new to this tool. By means of command activity I don't know where to use this count and how to use this,So Please clear me this command activity in detail or if possible provide with the another solution.

Thanks,
Vishal J.
IBM Websphere Datastage Certified Professional
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

"Command Activity" lets you execute a shell command. This would be a SQL Command to your database to get the results from the table. This result can be check in the job sequence and can be used as the condition on whether or not to execute a job.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Btw, this is part of "Sequence" jobs.

You can also include a sub-query in job1 as

yourNormalQuery
where
not exists (select 1 from Table1)

This is assuming that your job does not overwrite or re-create anything.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

A search for USERSTATUS or DSSetUserStatus will give you another approach if command line sql queries are out of your comfort zone.
-craig

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