How can I delete a sequential file after running the job?

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

Moderators: chulett, rschirm, roy

Post Reply
ScottDun
Participant
Posts: 61
Joined: Thu Dec 10, 2015 9:51 am

How can I delete a sequential file after running the job?

Post by ScottDun »

Hi,

I am trying to see if it is possible to delete a sequential file during/after my run of the job? I have 2 sequence jobs and 4 parallel jobs. The 1st sequence job is where I am extracting the sequential file and it gets passed to the 2nd sequence job which will trigger 3 parallel jobs (the 4th parallel job has nothing to do with the input file).

I want to have this sequential file deleted after I load the ODBC connectors in my 3 parallel jobs. Is this possible? I would prefer to use an execute command stage in my main sequence job. The Job Activity before my end loop is what triggers the second seq job to run so if there is a way to tell that stage that it is run successfully (using a condition), then send it to the execute command stage to delete that file.
SCOTTDun
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sure and you've got options here. One place would be an "After Job" process, specifically an ExecSH to issue the delete command to the O/S in whatever job needs it last. Heck, even Before Job as long as it is no longer needed at that point. Or as noted you could add an Execute Command stage wherever in the Sequence job would be appropriate, meaning after the point when any job would need it or would have it open. And any link in a Sequence job can use as a trigger the status of any previous step in order to control whether it 'fires' or not.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ScottDun
Participant
Posts: 61
Joined: Thu Dec 10, 2015 9:51 am

Post by ScottDun »

Image

So I went ahead and added the Execute Command stage (number 2) with the command 'rm' and the parameter is the filepath of the sequential file. At number 1, the trigger is currently Unconditional, meaning Expression 'N/A'.

What would need to be added to this, if anything at all? Meaning, would I have to change the trigger condition to something else? If so, what would it look like?

Also to mention, the sequential file has a '*' so that I can read multiple files.

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

Post by chulett »

Need to add a condition? Not necessarily as it would depend on what behavior you wanted. An unconditional trigger fires all the time, so use that if that is what you need. If you only want the file deleted at Step 2 if the job at Step 1 finished OK, make sure your trigger expression supports that. You also need to decide what should happen if the files (for whatever reason) cannot be deleted - so it pass control to the next step regardless or should it stop? Your trigger expressions would control that.

From what I recall, there should be an expression editor in the link to help you build the trigger syntax, this rather than having to type it all in by hand. Here you go, found this documentation on the subject which should apply to pretty much every version.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ScottDun
Participant
Posts: 61
Joined: Thu Dec 10, 2015 9:51 am

Post by ScottDun »

Thanks for the info. I am going to read this info
SCOTTDun
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sorry, should have started you at the parent topic so you get the full scope. You only need to supply all of that fancy expression editor syntax for a custom trigger and in my experience, most of the time you won't need a custom trigger.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ScottDun
Participant
Posts: 61
Joined: Thu Dec 10, 2015 9:51 am

Post by ScottDun »

Hi,

So I created a custom trigger in the execute command stage "JobActivity.$JobStaus = 'Executed OK'. This deletes the file when the job is done running. I have a problem, however, when I put an error in the job to abort it... The job still deletes the file. What should the proper syntax be to delete the file only if the job is successful?

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

Post by chulett »

JobActivity_Stage_Name.$JobStaus = DSJS.RUNOK

Those variables are mentioned all over the place but here is one entry with all of them: http://www-01.ibm.com/support/knowledge ... ml?lang=en
-craig

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