Adding A line to Existing File From BASIC Routine

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
Rubu
Premium Member
Premium Member
Posts: 82
Joined: Sun Feb 27, 2005 9:09 pm
Location: Bangalore

Adding A line to Existing File From BASIC Routine

Post by Rubu »

Hi

I am writing to a Seq File from After Job routine using WRITESEQ. By nature this command start writing from the starting of the file pointer. Since OpenSeq opens a file with the pointer at the begining it always overwrite the existing data.

My requirement is, I want to add new rows to the existing file with its data intact. Please help .

Regards
Rubu
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Rubu,

the file pointer needs to be set to the EOF so that you can append to a sequential file. If your file pointer is MySeqFilePtr (i.e. OPENSEQ '/tmp/hello.txt' TO MySeqFilePtr THEN ... ELSE ...) then executing the command

Code: Select all

SEEK MySeqFilePtr, 0, 2 THEN ... ELSE ...
will position the pointer to the end of file (the first parameter, 0, is the number of bytes offset and the 2nd parameter value of 2 tells that this position is relative to the end-of-file, see 6-522 of the Basic Manual for details).

I am not 100% sure that the sequential file is actually closed when you enter the after-job routine; but you will find out soon enough when you test this solution.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ArndW wrote:I am not 100% sure that the sequential file is actually closed when you enter the after-job routine; but you will find out soon enough when you test this solution.
It is. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Craig - thanks for the info :D It's always good to get positive confirmation
Post Reply