RELEASE statement
Syntax
RELEASE [ file.variable [ ,record.ID ] ] [ ON ERROR statements ]
Description
Use the RELEASE statement to unlock, or release, locks set by a FILELOCK, MATREADL, MATREADU, READL, READU, READVL, READVU, or OPENSEQ statement. These statements lock designated records to prevent concurrent updating by other users. If you do not explicitly release a lock that you have set, it is unlocked automatically when the program terminates.
file.variable specifies an open file. If file.variable is not specified and a record ID is specified, the default file is assumed (for more information on default files, see the OPEN statement). If the file is neither accessible nor open, the program terminates with a run-time error message.
record.ID specifies the lock to be released. If it is not specified, all locks in the specified file (that is, either file.variable or the default file) are released. If either file.variable or record.ID evaluates to the null value, the RELEASE statement fails and the program terminates with a run-time error message.
When no options are specified, all locks in all files set by any FILELOCK, READL, READU, READVL, READVU, WRITEU, WRITEVU, MATREADL, MATREADU , MATWRITEU , or OPENSEQ statement during the current login session are released.
A RELEASE statement within a transaction is ignored.
The ON ERROR Clause
The ON ERROR clause is optional in the RELEASE statement. The ON ERROR clause lets you specify an alternative for program termination when a fatal error is encountered during processing of the RELEASE 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.
Examples
The following example releases all locks set in all files by the current program:
RELEASE
The next example releases all locks set in the NAMES file:
RELEASE NAMES
The next example releases the lock set on the record QTY in the PARTS file:
RELEASE PARTS, "QTY"