CLOSE


The CLOSE statement closes the currently opened instance of a specified file (either disk or cache) when required processing is completed. Note that, while OPEN statements may be needed to switch between disk and cache versions of a file or used for performance reasons, CLOSE statements are normally not necessary since APPX takes care of closing files automatically.

     CLOSE       PHYSICAL?      
    (1)            (2) (3)                     (4)

(1) T/F execution conditions

(2) Application ID

(3) File name

(4) Physical close? (Y/N)

Using the Statement

The CLOSE statement applies only to the last OPEN operation for the file specified. If no preceding OPEN statement for the specified file is encountered, the file for the current database is closed.

The CLOSE statement closes the currently opened instance of a file, either disk or cache. Like memory files, there can be only a single instance of a cached file. There is not a separate instance of a cached file for each database.

Although a file cannot be physically opened again once it has already been opened, it may be logically opened many times, once for each process in the process family. In like manner, you can use the CLOSE statement to logically close the file in the current process or to physically close the file for all processes by specifying N or Y, respectively, in the Physical? parameter.

Regardless of whether a file is logically or physically closed, you must open it again before using it in the current process. However, the file may still be logically open in other processes in the process family, and those processes can continue to use the file without having to reopen it.

Restrictions

Note that when a file is physically closed, all holds previously specified are lost, and all file-read positions are set to the beginning of the file or the beginning of the range in the file, if so specified.

Statement Ignored

If a file is not currently open, the CLOSE operation has no effect.

Related Statements

OPEN

Example

The following example performs a logical close on the ORDER file:

          CLOSE    TAR ORDER     PHYSICAL?      N