delete the last row

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

ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The following is how you might do it in DataStage BASIC. Error handling has been omitted for clarity. File1 is the original file, file2 contains one fewer line (the final line) than file1. File1 has been opened for sequential access on variable F1, file2 has been opened for sequential access on variable F2.

Code: Select all

PrevLine = ""
LineCount = 0
Loop
While ReadSeq Line From F1
   If LineCount Then WriteSeq PrevLine To F2 Else NULL
   LineCount += 1
   PrevLine = Line
Repeat
The two CloseSeq statements have also been omitted for clarity.
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