HP 3000 Manuals

MODE Command [ HP ALLBASE/4GL Developer Reference Manual Vol. 2 ] MPE/iX 5.0 Documentation


HP ALLBASE/4GL Developer Reference Manual Vol. 2

MODE Command 

The MODE command specifies the way files are used in the current process.

Formats 

     {*READ  }
MODE {*WRITE } file_ref...
     {*LOCK  }
     {*UNLOCK}

Parameters 

file_ref 

The name of the application data files or HP TurboIMAGE/iX data sets that
you want to specify access conditions for.  Use the HP ALLBASE/4GL file
name, not the external file name.

Description 

The MODE command specifies the way the application's data files are
accessed in the current process.


NOTE You can only use the MODE command in a process. It cannot be used in a function.
Each MODE command remains in effect until another process is initiated. You can include more than one MODE command in a process, but subsequent MODE commands in a process will not affect the usage mode of any files that are open at the time. You can specify as many file references as you wish. The command argument *READ specifies that the file or files are available for reference purposes only. The files cannot be updated in any manner. The *READ argument is the default condition and applies to all files not explicitly specified in a MODE command. The MODE command does not have any effect on HP ALLBASE/SQL table locking. KSAM Files With KSAM files, the MODE *LOCK, MODE *WRITE and MODE *UNLOCK forms of the command all perform the same function. They each specify that the file or files are available for reading and writing. Under any of these modes, HP ALLBASE/4GL locks the file at the first access that reads or writes a file record. (Locking does not occur if the file access command uses the *NOLOCK argument, and the file has not been locked by an earlier access.) These different forms of the MODE commands are provided to allow application portability to and from other operating systems that allow record based locking of indexed files. The MODE command operates in conjunction with the FILE command to determine the file locking procedure used by HP ALLBASE/4GL. Refer to the FILE command (\SAM ) for a description of the HP ALLBASE/4GL file locking system. HP TurboIMAGE/iX Data Sets With HP TurboIMAGE/iX files, the MODE *LOCK, MODE *WRITE, and MODE *UNLOCK forms of the command operate also specify that the file or files are available for reading and writing. MODE *WRITE should be used with care. It does not guarantee any transaction integrity, but can be used by developers without significant knowledge of HP TurboIMAGE/iX locking. When using MODE *WRITE, a data set level lock is placed. The record remains locked to the current process until another record is accessed through the same file buffer, the buffer is cleared, the file is closed, or a FILE *UNLOCK command is executed.
NOTE When a lock is released, all locks held on the database are released.
MODE *UNLOCK is similar to MODE *WRITE, except that a lock is not released until a specific FILE *UNLOCK command is executed. If a data set is locked, another user or process cannot lock the same data set while the lock is current. The command argument *LOCK specifies that the process has write access to the file. Each file is locked when it is first accessed. The file or files remain locked until the end of the process, or the files are closed. While a file is locked to a process that uses the *LOCK form of the MODE command, another process or user can read the file provided that the file is accessed under MODE *READ. However, while the MODE *LOCK command is in effect, other processes or users cannot write to the file or lock the file. The MODE command and the DM IMAGE *MODE command. The *MODE command may be used in conjunction with the DM IMAGE *MODE command. The two commands perform similar but discrete functions. The DM IMAGE *MODE command sets the access mode that HP ALLBASE/4GL uses to access an HP TurboIMAGE/iX database. The access mode specifies read and write access restrictions as well as enforcing locking requirements. The MODE command specifies, to HP ALLBASE/4GL, the read and write permissions for a single data set, and also specifies how HP ALLBASE/4GL should perform implicit locking of files if no DM IMAGE *LOCK commands are used to lock a file. The capability provided by the MODE command must be a subset of a DM IMAGE *MODE command. For example, DM IMAGE *MODE *MODLOCK and MODE *READ can be used together because reading is a subset of DM IMAGE *MODE *MODLOCK capability, but DM IMAGE *MODE *READLCK and MODE *WRITE cannot be used together, because the MODE command specifies more capability than the DM IMAGE *MODE command. If the MODE command used in conjunction with a DM IMAGE *MODE command is not a subset of the DM IMAGE *MODE command, an error will occur at run-time if an action is attempted that requires more capability thatn the DM IMAGE *MODE command provides. Example 1 MODE *WRITE stock stck_trn This command specifies that the two files stock and stck_trn may be updated until another process is initiated. All other files may be accessed for reference purposes only.


MPE/iX 5.0 Documentation