Reading and Writing to same sequential 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
naren6876
Participant
Posts: 233
Joined: Mon Feb 07, 2005 7:19 pm

Reading and Writing to same sequential file

Post by naren6876 »

Hi,

I am trying to Read and Write to same sequential file (i am overwriting the sequential file on Target side). But it fails as it is not reading from the file.

But my observation is, if i change the filename on the target side it is reading data from the file and writing to new file.

Any help would be highly appreciated.

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

Post by chulett »

What help do you need? You cannot write back to the same file you are reading from, doesn't matter what tool we're talking about. Think about what you are asking it to do when overwriting the target.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Re: Reading and Writing to same sequential file

Post by vivekgadwal »

naren6876 wrote:Hi,

I am trying to Read and Write to same sequential file (i am overwriting the sequential file on Target side). But it fails as it is not reading from the file.

But my observation is, if i change the filename on the target side it is reading data from the file and writing to new file.

Any help would be highly appreciated.

Thanks,
naren
It is quite obvious that once you open a file, you can write to it. You just try doing it manually on a Windows machine and see if you can do it. If you cannot, then this would extend to the tool too.
A solution to your problem is to write to another file and use another job OR a Unix command to rename the file back to the original name.
Vivek Gadwal

Experience is what you get when you didn't get what you wanted
ReachKumar
Participant
Posts: 29
Joined: Wed Jan 06, 2010 7:18 am

Post by ReachKumar »

Yes you can use Unix command to rename the Target file to the Source file in the after job sub routine property of Data Stage job.
Regards,
Kumar
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

... but not on a Windows server unless there's some kind of UNIX emulator, such as MKS Toolkit, available.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

If what you want to do is read all the data in from a file, apply some processing, and then write the data back out to the file, then that isn't really what DataStage jobs do. They don't hold data sets in memory, they typically process just one row at a time. You need to store the data somewhere while the transformation is being applied, and then write it back to the original file afterwards.

You can read the original file, pass through a Transformer, back out to a temporary file, and then have another link coming out of the temporary file and in to another Sequential File with the original name. That will do what you want to do in one job, but does involve landing the data into a temporary file. Or you can do the delete/rename thing mentioned by others.
Phil Hibbs | Capgemini
Technical Consultant
Post Reply