HPlogo KSAM/3000 Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 3 USING KSAM FILES IN COBOL PROGRAMS

CKUNLOCK

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

A call to CKUNLOCK unlocks a KSAM file dynamically locked by CKLOCK.

   CALL "CKUNLOCK" USING filetable, status

A file locked by CKLOCK is released for use by other users with a call to CKUNLOCK. (If you log off from any connection with the system, the file is also unlocked.) Since dynamic locking takes place during shared access to the same file by more than one user, it is important that any file locked by CKLOCK be unlocked as soon as possible by CKUNLOCK.

To use CKUNLOCK, the file must be opened for shared access with dynamic locking allowed. This can only be done by calling CKOPENSHR to open the file, not CKOPEN.

PARAMETERS

filetable

an 8-word record containing the number and name of the file, its input-output type, access mode, and a code indicating whether the previous operation was successful and if so, what it was. (Refer to Filetable Parameter discussion earlier in this section.)

status

one-word (two 8-bit characters) set to a pair of values upon completion of the call to CKUNLOCK. It indicates whether or not the file was successfully unlocked and if not, why not. The status word is to"00" if the file was unlocked successfully; to "31 "if the file was not locked; or to "9n" where n is a binary file system error code if the call fails for any other reason. (Refer to Status Parameter discussion earlier in this section.)

USING CKUNLOCK

After calling CKUNLOCK, you should always check the status parameter to make sure that the procedure was executed successfully. When successful, the file locked by CKLOCK is again made available for access by other users. If the file was not locked by CKLOCK, when CKUNLOCK is called, status is set to "31."

EXAMPLES

The following example unlocks a file previously locked by CKLOCK. (Refer to the CKLOCK example.)

DATA DIVISION. 

. 

. 

. 

77     RESULT            PICTURE 9(4)           VALUE 0. 

01     STATUSKEY. 

    02   STATUS-KEY1  PICTURE X              VALUE " ". 

    02   STATUS-KEY2  PICTURE X              VALUE " ". 

01     FILETABLE. 

    02   FILENUMBER   PICTURE S9(4)   COMP   VALUE 0. 

    02   FILENAME     PICTURE X(8)           VALUE "KSAMFILE". 

    02   I-O-TYPE     PICTURE S9(4)   COMP   VALUE 0. 

    02   A-MODE       PICTURE S9(4)   COMP   VALUE 0. 

    02   PREV-OP      PICTURE S9(4)   COMP   VALUE 0. 



PROCEDURE DIVISION. 

. 

. 

. 

    CALL "CKUNLOCK" USING FILETABLE, STATUSKEY. 

    IF STATUSKEY ="00" 

      THEN DISPLAY "CKUNLOCK IS OK" 

    ELSE IF STATUSKEY ="31" 

           THEN DISPLAY="FILE NOT PREVIOUSLY LOCKED BY THIS PROCESS" 

         ELSE IF STATUS-KEY1 ="9" 

                 THEN CALL"CKERROR" USING STATUSKEY, RESULT 

                      DISPLAY "ERROR NO.", RESULT. 
Feedback to webmaster