To skip a job for null dataset

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

Post Reply
gssr
Participant
Posts: 243
Joined: Fri Jan 09, 2009 12:51 am
Location: India

To skip a job for null dataset

Post by gssr »

Hi all,
I am using the target dataset of a job1 as an input of job2.I have skip the job2 if no records was passed to the target dataset in the job1
How can i achieve this,Can anyone suggest me a solution..

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

Post by chulett »

Use a sequence job to check either the size of the dataset or how many rows were written to it in the previous job and then only run the second job when that comes back non-zero.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Call job1 from a sequence job, after that completes do an execute command stage of "orchadmin describe -f {YourDataSetFileDescriptor}", then parse the output for the last line starting with " records" and then take the numeric value after the ":" character. You can then use this number of records to decide whether or not to call job2.

Another method to get the number of records in the dataset would be to use a call to DSGetLinkInfo() to get the number of rows that went down a particular link in job1.
gssr
Participant
Posts: 243
Joined: Fri Jan 09, 2009 12:51 am
Location: India

Post by gssr »

We are running in daily cycle, So it will not be a null dataset.
The problem in my case is :The records of the last run was loading again in the dataset creating duplicate records.

Thanks
RAJ
gssr
Participant
Posts: 243
Joined: Fri Jan 09, 2009 12:51 am
Location: India

Post by gssr »

My requirement is : Not to load the last run records to the database if the current run produses no records.
Can this be achievable by any other way(By not skipping the job)

Thanks.
RAJ
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Use a call to DSGetLinkInfo() to get the information on the number of rows processed down a link.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sounds like you may just need to make sure you have 'overwrite' turned on. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
gssr
Participant
Posts: 243
Joined: Fri Jan 09, 2009 12:51 am
Location: India

Post by gssr »

Actually, i am tring an option of skipping the job, But if there is any other option, i can try that too...
Hence i tried to clarify my requirement... :oops:

Thanks,
RAJ
ljulienne
Participant
Posts: 10
Joined: Tue Jun 09, 2009 3:14 am
Location: Lyon, FRANCE
Contact:

Post by ljulienne »

Otherwise you can create a technical field in your dataset which is different each time your job run and store this parameter in a technical table. Next before launching your job, you check if new records are present or not.
Laurent JULIENNE
SYNCER
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

If you overwrite the previous dataset each time, loading it empty should not be an issue. Is there some reason you cannot simply do that?
-craig

"You can never have too many knives" -- Logan Nine Fingers
HariK
Participant
Posts: 68
Joined: Thu May 17, 2007 1:50 am

Post by HariK »

If for some reason you need the past data then add a date field to data set.
In job1 set the derivation as sysdate for this field.
add filter on this field in the job2.
gssr
Participant
Posts: 243
Joined: Fri Jan 09, 2009 12:51 am
Location: India

Post by gssr »

i am overwriting the file, but while loading the last run records are loaded...
Is ther any problem whiile overwriting the file without any records or do i have to change any properties in dataset ??

Thanks,
RAJ
hemaarvind1
Participant
Posts: 50
Joined: Mon Jan 21, 2008 9:35 am

Post by hemaarvind1 »

you can create a new field in the job called 'modified date' which holds the date when the record is updated. If there are new records, compare the date with modified date. Add a filter such that only last loaded records are loaded. this can be achieved by comparing the record load date with the ,modified date column.
gssr
Participant
Posts: 243
Joined: Fri Jan 09, 2009 12:51 am
Location: India

Post by gssr »

Thank you all for your replies,
But now i have a doubt about the dataset stage
:: I am overwriting a dataset here, If there are no records passed ,then the dataset should be emptied.But i am having the past run records. Why is it so....
Please clarify my doubt

Thanks to all once again,
RAJ
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sending zero records to a dataset with the Update Policy set to Overwrite results in an empty dataset, regardless of what was in there before. Something else must be going on.
-craig

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