How to write in same file which is also a source file ?

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
sid19
Participant
Posts: 64
Joined: Mon Jun 18, 2007 12:17 am
Location: kolkata

How to write in same file which is also a source file ?

Post by sid19 »

Hi All,



I have one problem, I am using a unix .text file as a one of the source file for a parallel Job, after look up and funnel stage one out put file(.txt) will come from the job which one should have same name (with the same path) as a source file.

How Can I handle this situation , one solution I have that is, we can give the another name to out put file and from unix overwrite this new file to old one.

but my question is how can i do this from Data Satge Parallel

Thanks,
Shamim
Sid
mansoor_nb
Participant
Posts: 48
Joined: Wed Jun 01, 2005 7:10 am

Post by mansoor_nb »

you can do one thing, create the output staging file and then in the after job subroutine delete the source file and rename the output staging file with the source file name.
aakashahuja
Premium Member
Premium Member
Posts: 210
Joined: Wed Feb 16, 2005 7:17 am

Post by aakashahuja »

Read the source file in to another file / dataset for intermediate staging before doing any of your processing....
L'arrêt essayant d'être parfait… évoluons.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Re: How to write in same file which is also a source file ?

Post by JoshGeorge »

Regardless of Px job or Server job, you can create the output file with a temporary name (Ex: temp.txt). Now in job properties afterjob ExecSh specify on successfull completion (Mind this condition) of the job, rename the temp file name to source file name

mv temp.txt sourcefile.txt

This will overwrite sourcefile.txt with temp.txt and temp.txt will be removed also.
sid19 wrote:One solution I have that is, we can give the another name to out put file and from unix overwrite this new file to old one. but my question is how can i do this from Data Satge Parallel
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
sid19
Participant
Posts: 64
Joined: Mon Jun 18, 2007 12:17 am
Location: kolkata

Hi Akash

Post by sid19 »

aakashahuja wrote:Read the source file in to another file / dataset for intermediate staging before doing any of your processing....
Hi Akash,
Can u please give some detail about dataset file so that I can use it in my job
Sid
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Read Joshy's answer again. He gave a very viable solution.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply