Accessing Files Programmer's Guide (32650-90885)

154 Chapter12
Sharing a File
Simultaneous Access of Files
action taken depends upon the current use of the file versus the access requested.
Exclusive access
This option is useful when you wish to update a file and wish to prevent other users or
programs from reading or writing on the file while you are using it; thus, no user can read
information that is about to be changed, nor can he alter that information. To override the
programmatic option under which the file would be opened and request exclusive access,
you could use the EXC keyword parameter in the FILE command:
FILE DATALIST;EXC <---- Requests exclusive access
RUN FLUPDATE
NOTE
In all cases, when the first accessor to a file opens it with Exclusive (EXC)
access, all other attempts to open the file fails.
Table 12-1. File Sharing Restriction Options
ACCESS
RESTRICTION
FILE\
PARAMETER
DESCRIPTION
Exclusive Access EXC After file is opened, prohibits concurrent access in any mode
through another HPFOPEN/FOPEN request, whether issued
by this or another program, until this program issues
FCLOSE or terminates.
Exclusive Write
Access
SEMI After file is opened, prohibits concurrent Write access
through another HPFOPEN/FOPEN request, whether issued
by this or another program, until this program issues
FCLOSE or terminates.
Shareable
Access
SHR After file is opened, permits concurrent access to file in any
mode through another HPFOPEN/FOPEN request issued by
this or another program, in this or any session or job.