Protect: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
m (edit)
m (edit content)
Line 21: Line 21:


==Parameters==
==Parameters==
'''File-ref''' is the name and path of the file to be protected.<br>
'''File NAME''' is the name and path of the file to be protected.<br>
'''READ''' allows all workstations to read file data, but not to change it (the file is write protected). This parameter restricts all workstations, including the workstation that issues the command.<br>
'''READ''' allows all workstations to read file data, but not to change it (the file is write protected). This parameter restricts all workstations, including the workstation that issues the command.<br>
'''RELEASE''' removes RESERVE restrictions which have been initiated by the current workstation for the specified file. This parameter can be issued only from the workstation that initiated the RESERVE restrictions.<br>
'''RELEASE''' removes RESERVE restrictions which have been initiated by the current workstation for the specified file. This parameter can be issued only from the workstation that initiated the RESERVE restrictions.<br>

Revision as of 11:51, 26 December 2011

The Protect command enables and disables two types of file protection.

Comments and Examples

Multi-user file protection is controlled with the RESERVE and RELEASE parameters. PROTECT with the RESERVE parameter allows a file or file name to be reserved for exclusive use at the workstation issuing the command.

PROTECT CUSTOMER.FIL RESERVE

RESERVE status keeps a file locked even when the file is not open. It also reserves the file name, even when the file is freed, so that no other workstation can create a file with the same name. The RELEASE parameter removes this exclusive control.

PROTECT CUSTOMER.FIL RELEASE

The second type of file protection is controlled with the READ and WRITE parameters. The READ parameter makes a file read-only (makes it write-protected) until changed by another PROTECT command with a WRITE parameter. Permissions at the operating system determine the success or failure or the READ and WRITE options.

PROTECT CUSTOMER.FIL, READ
PROTECT CUSTOMER.FIL, WRITE

For additional information about locking or sharing both files and records, see the Multi-User Programming chapter.

Syntax

Parameters

File NAME is the name and path of the file to be protected.
READ allows all workstations to read file data, but not to change it (the file is write protected). This parameter restricts all workstations, including the workstation that issues the command.
RELEASE removes RESERVE restrictions which have been initiated by the current workstation for the specified file. This parameter can be issued only from the workstation that initiated the RESERVE restrictions.
RESERVE prevents all others from using the specified file.
WRITE removes READ-only status and allows all workstations to READ and WRITE to the file.

Technical Considerations

  1. An alternative to releasing locked files with PROTECT RELEASE is to use the CLOSE statement with its RELEASE parameter. (This can only be done when the file to be released is currently open.)
  2. An alternative to reserving files with PROTECT RESERVE is to use the OPEN statement with its RESERVE parameter.
  3. The STATUS ALL command provides a list of file name reservations which have been issued from the current workstation.
  4. All file name reservations issued from a particular workstation are automatically released when that workstation exits from BR.
  5. The PROTECT command may be used to reserve a file's name when a file does not exist or when the FREE command has been used to delete the file.
  6. File locking with the PROTECT command differs from file locking with the NOSHR parameter in two main ways: PROTECT keeps a file locked even when the file is not open; and PROTECT does not prevent other opens to the same file by the same workstation.
  7. READ and WRITE file protection can be used on single-user or multi-user systems. The READ protection is not removed from the file when the workstation exits from BR.