How to create a new file using WriteSeq

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
sankar18
Participant
Posts: 34
Joined: Mon Dec 16, 2002 1:18 am

How to create a new file using WriteSeq

Post by sankar18 »

Hi,

How create a new file using WriteSeq. or using other statement.
Is there any other approach to create a file in routine.

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

Post by ray.wurlod »

OpenSeq opens a channel to the I/O system.
It is possible, therefore, to "open a file for writing" even though the file does not yet exist. In this case, the ELSE clause of the OpenSeq statement is executed, and the STATUS() function returns 0.
If the channel is closed (CloseSeq) without any form of Write statement (that is, WeofSeq, WriteSeq or WriteBlk) having been performed, the file will still not exist.
If the channel is closed and any form of Write statement has been executed, then the file will exist (provided permissions, etc., allow it).
If you want to guarantee the creation of a zero length file, even though you end up writing nothing to it, you can simply write an end of file mark (WeofSeq). Another way is to use the CREATE statement inside the ELSE clause of the OpenSeq statement.
You can find all of these statements in the BASIC manual.
Alternately, prior to opening the file, you can use the touch command at the operating system level to create it. This command exists for all UNIX platforms, and ships with DataStage (as touch.exe) for Windows platforms.


Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
Post Reply