Rename a file and empty a file

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
Sant
Participant
Posts: 15
Joined: Thu May 12, 2005 12:08 am

Rename a file and empty a file

Post by Sant »

Hi everybody


I have a job which read the Balance_CG.csv file for write in a Oracle table.
After reading this file, I must copy the data in a new file named Balance_CG_yyyymmdd.csv and empty the first file.


How can I do that ?

Thank you everybody for you help.

Frederic from Paris (France)
pnchowdary
Participant
Posts: 232
Joined: Sat May 07, 2005 2:49 pm
Location: USA

Post by pnchowdary »

Hi Sant,
I must copy the data in a new file named Balance_CG_yyyymmdd.csv and empty the first file.
You can copy the data into a new file by simply using a transformer after you read the old file and then write to a new file called Balance_CG_yyyymmdd.csv in a sequential file stage.

By emptying the first file, if you meant delete the file
Then you need to call a shell script in the After job routine to delete the file ( you can use rm <filename>). If you want an empty file with the same name, use touch command after rm command in your shell script to create an empty file.
Thanks,
Naveen
ukyrvd
Premium Member
Premium Member
Posts: 73
Joined: Thu Feb 10, 2005 10:59 am

Post by ukyrvd »

If you copying/renaming needs to be done after the job finishes then you can use after-job-subroutine from job properties.

On the other-hand if its right after reading from file, while the job is running .. I dont think you can achieve this.. as DataStage expects the input-file/data to be there untill job finishes. If you just want to add data to the existing file you can probably use before-stage subroutine from XFM rigt after sequential stage.
thank you
- prasad
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

An after-job move script is all you need.
Post Reply