OPEN FILE command

From m204wiki
Jump to: navigation, search

Summary

Privileges
Any user
Function

Syntax

OPEN [FILE] filename [AT location] [[,defupdt1] [,defupdt2]]

Where:

  • filename is the name of the Model 204 file to be opened.

  • location

    • For Parallel Query Option/204 files, this is the symbolic name (as many as eight characters) that refers to the location of the node on which the remote file resides. An unquoted equal sign (=) specifies that the file is local.

    • If remote, must match a symbolic destination name specified in the DESTINATION parameter of the relevant local client DEFINE PROCESS command.

  • defupdt1 is the name of the fixed-length deferred update data set. If this option is specified, deferred updates to KEY and NUMERIC RANGE fields are written to the fixed-length deferred update data set (1 to 8 characters in the form TAPExxxx).

  • defupdt2 is the name of the variable-length deferred update data set. If this option is specified, deferred updates to ORDERED fields are written to the variable-length deferred update data set. All deferred index updates are written to defupdt2 if defupdt1 is not specified. If defupdt2 is not specified, updates to ORDERED fields are not deferred.

    Deferred updates are updates to the Model 204 file index that are saved and applied all at the same time.

    For user privileges needed to open deferred update data sets through a security interface, see Security interfaces.

    For information about opening remote files in deferred update mode, see PQO: Remote files and scattered groups.

Syntax notes

A comma is required if a deferred update name is specified. If the comma is omitted, the name is ignored and no message is generated.

Example

The following command opens the Model 204 file CENSUS in deferred update mode. Hashed index deferred updates are written to defupdt1, TAPEFIX, and Ordered Index deferred updates are written to defupdt2, TAPEVAR:

*** M204.0620: FILE CENSUS OPENED *** M204.1203: CENSUS WAS LAST UPDATED ON 89.003 JAN03 10.24.12 *** M204.0656: UPDATES DEFERRED TO TAPEFIX TAPEVAR

The following command opens the Model 204 file CENSUS in deferred update mode. All index updates are written to defupdt2, TAPEVAR:

OPEN FILE CENSUS,,TAPEVAR *** M204.0620: FILE CENSUS OPENED *** M204.1203: CENSUS WAS LAST UPDATED ON 89.041 FEB10 16.34.27 *** M204.0656: UPDATES DEFERRED TO TAPEVAR

The following command opens the Model 204 file CENSUS in deferred update mode. Hashed index updates are written to TAPEFIX. Ordered Index updates are not deferred:

OPEN FILE CENSUS,TAPEFIX *** M204.0620: FILE CENSUS OPENED *** M204.1203: CENSUS WAS LAST UPDATED ON 88.335 DEC01 11.52.36 *** M204.0656: UPDATES DEFERRED TO TAPEFIX

Usage notes

A Model 204 file is a collection of records. A file group is a collection of Model 204 files that Model 204 treats logically as a single file. An individual file can be a member of several different groups. Any user can open several files or groups during a single Model 204 session. These remain open until a CLOSE, LOGOUT, or DISCONNECT command is issued or until the user is restarted.

The file or group specified in the most recent OPEN command is considered the default file or group. Thus, a successful OPEN command causes the current default file or group to be replaced. If an OPEN command is rejected, the default is not changed.

If no specific file or group specification is included in the OPEN command, as in:

OPEN CENSUS

Model 204 attempts to determine whether a file or a group is to be opened. Model 204 searches first for a temporary group that has the specified name. If no temporary group is found, Model 204 tries to open a permanent group by using that name. If a permanent group cannot be found, Model 204 searches for a file by that name. Further OPEN processing depends upon what type of file or group is actually being opened.

There are three types of files:

  • Public

  • semi-public

  • Private

If the file is public, Model 204 opens it without asking for a file password. You are given the default file privileges assigned to the file by the file manager.

If the file is semi-public or private, Model 204 asks you to enter a valid password as shown:

***M204.0347: PASSWORD [password [:new-password]]

where password or new-password is a valid password for the file to be opened (1 to 8 characters); it cannot contain spaces, commas, or colons. Each file can have several passwords defined for it. If you enter a valid password, the file is opened with the file privileges associated with that password.

For a semi-public file, if you do not know the password for the file and simply enter a carriage return, the file is opened and you are given the default privileges for the file. An invalid password also causes the file to be opened, but only default privileges are granted. For a private file, you must enter a valid password or the file is not opened. If the file privileges for a file include the ability to update data, the following message is displayed when the file is successfully opened:

*** M204.0620: FILE filename OPENED

If the file privileges do not allow update, or if the OPEN occurs while Model 204 is running the RESTART to perform recovery, the following is displayed:

*** M204.0620: FILE filename OPENED -- NO UPDATES ALLOWED

With application subsystems, if you open a file defined as optional to the subsystem, you are granted the privileges assigned in the subsystem definition. Such privilege assignment takes places regardless of the default file privileges assigned the file. A file defined as required to the subsystem is opened implicitly when you enter the subsystem.

If you have the appropriate user privileges (established by the login), you can change a file password at the time that the file is opened. When Model 204 prompts for the password, you can enter the current and desired password, separated by a colon, as shown above. If the old password is invalid, the new password specification is ignored. If the new password is too long, or if you do not have the appropriate privileges, Model 204 rejects the password. If both the old and the new file passwords are valid, Model 204 displays a message that the password has changed. The new file password has the same file privileges as those associated with the old password.

The logic of OPEN command processing

The following psudeo-code shows how OPEN processing applies the order of precedence to Model 204 entities (file, temporary group, and permanent group) that all have the same name: something.

OPEN something ... If there is an open temp group named 'something' then re OPEN TEMP GROUP something elseif there is an open perm group named 'something' then re OPEN PERM GROUP something elseif there is a defined temp group named 'something' then OPEN TEMP GROUP something elsif there is a defined perm group named 'something' then OPEN PERM GROUP something else try to re OPEN or OPEN file something ifend