IBM InfoSphere DataStage, Version 11.3.1
CLOSE statement
Syntax
CLOSE [file.variable] [ON ERROR statements]
Description
Use the CLOSE statement after opening and processing a file. Any file locks or record locks are released.
file.variable specifies an open file. If file.variable is not specified, the default file is assumed. If the file is neither accessible nor open, or if file.variable evaluates to the null value, the CLOSE statement fails and the program terminates with a run-time error message.
The ON ERROR Clause
The ON ERROR clause is optional in the CLOSE statement. The ON ERROR clause lets you specify an alternative for program termination when a fatal error is encountered during processing of the CLOSE statement.
If a fatal error occurs, and the ON ERROR clause was not specified, or was ignored (as in the case of an active transaction), the following occurs:
- An error message appears.
- Any uncommitted transactions begun within the current execution environment roll back.
- The current program terminates.
- Processing continues with the next statement of the previous execution environment, or the program returns to the command prompt.
A fatal error can occur if any of the following occur:
- A file is not open.
- file.variable is the null value.
- A distributed file contains a part file that cannot be accessed.
If the ON ERROR clause is used, the value returned by the STATUS function is the error number.
Example
CLEAR
OPEN '','EX.BASIC' TO DATA ELSE STOP
READ A FROM DATA, 'XYZ' ELSE STOP
A<3>='*'
WRITE A ON DATA, 'XYZ'
CLOSE DATA
Last updated: 2015-03-09
PDF version of this information: