HP 3000 Manuals

UNLOCK Statement (Executable) [ HP FORTRAN 77/iX Reference ] MPE/iX 5.0 Documentation


HP FORTRAN 77/iX Reference

UNLOCK Statement (Executable) 

The UNLOCK statement unlocks a record that was locked by a READ on an
ISAM file.  If an ISAM file is shared by more than one process, you
should unlock the records after each READ if they are not being updated.
If the file is not shared, UNLOCK has no effect.

	       Click here to view figure.
            

-----------------------------------------------------------------------------------------------
|                       |                                  |                                  |
|         Item          |       Description/Default        |           Restrictions           |
|                       |                                  |                                  |
-----------------------------------------------------------------------------------------------
|                       |                                  |                                  |
| unit                  | Integer expression specifying    | Must be zero or positive.        |
|                       | unit number of a connected file. |                                  |
|                       |                                  |                                  |
-----------------------------------------------------------------------------------------------
|                       |                                  |                                  |
| variable_name         | Error code return.               | Must be an integer type.         |
| array_element         |                                  |                                  |
| scalar_record_field_name                                 |                                  |
|                       |                                  |                                  |
-----------------------------------------------------------------------------------------------
|                       |                                  |                                  |
| label                 | Statement label.                 | Must be an executable statement  |
|                       |                                  | in the same program unit.        |
|                       |                                  |                                  |
-----------------------------------------------------------------------------------------------

Semantics 

If the prefix UNIT= is omitted, unit must be the first item in the list.

If the ERR specifier is present and an error occurs during execution of
the UNLOCK statement, control transfers to the specified statement rather
than aborting the program.

If the IOSTAT specifier is present and an error occurs, the error code is
returned in the IOSTAT variable and the program is not aborted.  Refer to
Appendix A  for the IOSTAT error codes.

If the file is positioned at its beginning, a UNLOCK statement has no
effect upon the file.

                     Examples                                     Notes 
--------------------------------------------------------------------------------------

        OPEN(10,file='EMP_FILE',                    This example generates a report.
     +ACCESS='KEYED',STATUS='OLD',SHARED)           The READ statement locks the
111 READ (10,ERR=111,END=222) EMPLOY_REC            record when it reads it.  The
        UNLOCK (10,ERR=112)                         UNLOCK statement unlocks the
        PRINT 11,EMPLOYEE_REC.SSN,                  record to allow other users to
     +         EMPLOYEE_REC.FIRST_NAME              access it.  If the record is
     +         EMPLOYEE_REC.LAST_NAME,              locked by another user, the ERR
     +         EMPLOYEE_REC.SALARY,                 specifier causes the READ
     +         EMPLOYEE_REC.REVIEW_DATE             statement to be reexecuted until
        GOTO 111                                    the record is available.
112 PRINT *,'Can not unlock: ssn', EMPLOYEE_REC.SSN
      GOTO 111
222 PRINT *,'Employee salary review report printed'
      STOP



MPE/iX 5.0 Documentation