Basic Statement - CREATE
Moderators: chulett, rschirm, roy
Basic Statement - CREATE
Can you tell me what is wrong with this statement that this job control doesn't work?
OPENSEQ "C:\DS305Files\RecentEmployeesBASIC.txt" TO H.RECENT.EMPLOYEES ELSE
CALL DSLogInfo("Attempting to create the RecentEmployeesBASIC.txt file.", "Job seqRecentEmployeesBASIC")
CREATE H.RECENT.EMPLOYEES ELSE
CALL DSLogInfo("Unable to create the RecentEmployeesBASIC.txt file.", "Job seqRecentEmployeesBASIC")
*ABORT
END
The program is Aborted after CREATE statement .
Anka
OPENSEQ "C:\DS305Files\RecentEmployeesBASIC.txt" TO H.RECENT.EMPLOYEES ELSE
CALL DSLogInfo("Attempting to create the RecentEmployeesBASIC.txt file.", "Job seqRecentEmployeesBASIC")
CREATE H.RECENT.EMPLOYEES ELSE
CALL DSLogInfo("Unable to create the RecentEmployeesBASIC.txt file.", "Job seqRecentEmployeesBASIC")
*ABORT
END
The program is Aborted after CREATE statement .
Anka
akrzy,
Your code basically tries to open a sequential file and if it is not already there it will specifically CREATE an empty file. At least that is what is supposed to be happening.
Do not use the ABORT command, the preferred method of stopping any DataStage job from continuing is to call DSLogFatal().
I would recommend always using indentation in your code, it makes it so much easier to understand. The OPENSEQ also has an ON.ERROR that you should use, as a failure CREATE the file could result from the file existing but the user not having read or write access to it, or that the file is already open for writing.
Your code basically tries to open a sequential file and if it is not already there it will specifically CREATE an empty file. At least that is what is supposed to be happening.
Do not use the ABORT command, the preferred method of stopping any DataStage job from continuing is to call DSLogFatal().
I would recommend always using indentation in your code, it makes it so much easier to understand. The OPENSEQ also has an ON.ERROR that you should use, as a failure CREATE the file could result from the file existing but the user not having read or write access to it, or that the file is already open for writing.
Code: Select all
OPENSEQ "C:\DS305Files\RecentEmployeesBASIC.txt" TO H.RECENT.EMPLOYEES
ON.ERROR
CALL DSLogInfo('Got an error, status is "':STATUS():'".',"Job seqRecentEmployeesBASIC")
END
ELSE
CALL DSLogInfo("Attempting to create the RecentEmployeesBASIC.txt file.", "Job seqRecentEmployeesBASIC")
CREATE H.RECENT.EMPLOYEES
ELSE
CALL DSLogFatal("Unable to create the RecentEmployeesBASIC.txt file.", "Job seqRecentEmployeesBASIC")
END ;** of ELSE could not create sequential file
END ;** of ELSE file does not exist
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
What value is returned by STATUS() when OPENSEQ is executed?
The ELSE clause can be taken for a number of reasons - read the manual on OPENSEQ. For example, of C:\DS305Files does not exist, OPENSEQ will fail, you will not have a valid file variable, and CREATE is therefore doomed.
I don't use CREATE in general. Any operation that writes to the opened file will bring it into existence. Use CREATE only if you must have a 0-byte file if nothing is written to it.
The ELSE clause can be taken for a number of reasons - read the manual on OPENSEQ. For example, of C:\DS305Files does not exist, OPENSEQ will fail, you will not have a valid file variable, and CREATE is therefore doomed.
I don't use CREATE in general. Any operation that writes to the opened file will bring it into existence. Use CREATE only if you must have a 0-byte file if nothing is written to it.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
akrzy,
I agree with what Ray said - but I seem to remember a prolonged thread a coupel of weeks ago about the CREATE statement... I never use it but others argued that it ought to be used. My usual syntax for opening and/or creating a sequential file is:
The sequential file won't get created until the first WRITESEQ to it.
I agree with what Ray said - but I seem to remember a prolonged thread a coupel of weeks ago about the CREATE statement... I never use it but others argued that it ought to be used. My usual syntax for opening and/or creating a sequential file is:
Code: Select all
OPENSEQ 'myfile' TO MyFilePtr
THEN
WEOFSEQ MyFilePtr ;** truncate & overwrite existing file
END
ON.ERROR
STOP 'Bad open of myfile, Status is ':STATUS()
END
ELSE
PRINT 'Creating file "myfile"'
END
...