Page 1 of 1

Updating a Sequential File

Posted: Tue Mar 19, 2013 4:02 am
by chandra.shekhar@tcs.com
Hi,

Is there any way/logic to update records in a Sequential File ?

Posted: Tue Mar 19, 2013 7:12 am
by chulett
The short answer is no. You read in the file, update whatever needs updating and then write the result out to a new file. Of course, you could rename the new back to the old when you are done.

Posted: Tue Mar 19, 2013 7:27 am
by chandra.shekhar@tcs.com
I am too doing the same, but I thought better to ask than regret later. :wink:

Posted: Tue Mar 19, 2013 7:36 am
by chulett
That's the nature of sequential media.

You may be able to do something magical under the covers with C or something similar but for a "pure" DataStage solution there's no magic that I've ever seen. Of course, our resident Magician may say otherwise. :wink:

Posted: Tue Mar 19, 2013 1:13 pm
by ray.wurlod
I do this a lot when updating values files of Parameter Sets.

One approach is to overwrite the file entirely, using a Sequential File stage. That's the way I normally do it, particularly when the number of parameters in the Parameter Set is small.

The other is to use a Hashed File stage in a server job, opening the file's parent directory as if it were a table, and treating the file name as a record key. This having been done, the individual "fields" (lines) can be updated.

Posted: Tue Mar 19, 2013 1:15 pm
by chulett
Ah... the second part is where the magic happens. :wink: