Appending data to the 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
Simba
Participant
Posts: 22
Joined: Wed Dec 03, 2003 6:12 pm

Appending data to the same Sequential file

Post by Simba »

My job is creating four individual sequential files of the same structure. I want to append data in to the same seq file, instead of using four files. I have tried ExecSh with touch command with a sample job of two seq files and loading into the same seq file. For first time execution target seq file has only records from source seq file1, for next run target file has data from both source files 1 and 2. Some thing wrong i guess. please send me if any one of you has routine to create/delete a sequential file.

Thanks,
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

You cannot have multiple processes writing to the same sequential file, period. There's nothing that can be done about this because it's a block writing issue on all operating systems. You have a few choices: if all streams are in one job use a link collector; if separate jobs use a hash file to collect the data using a unique meaningless key to prevent row collisions; else use four separate sequential files and cat them into one and remove the quarter sized original files.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Sage advice.

You can cat the remaining three to the first, and make the rm command conditional on success of the cat command, using ordinary shell operators, for example

Code: Select all

cat file2 file3 file4 >> file1 && rm -f file2 file3 file4
The same can be done on Windows, use type instead of cat and del instead of rm.

Code: Select all

type file2 file3 file4 >> file1 && del /Q file2 && del /Q file3 && del /Q file4
(you can use wildcards with del, but not multiple file names; there's also a variant of copy that you could use)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply