beautypg.com

Compaq COBOL AAQ2G1FTK User Manual

Page 255

background image

Sharing Files and Locking Records

8.1 Controlling Access to Files and Records

WRITE
REWRITE
DELETE
UNLOCK

8.2 Choosing X/Open Standard or Compaq Standard File Sharing

and Record Locking

Compaq COBOL offers two methods of controlling potential conflicts of multi-user
file access between simultaneously running processes:

Compaq standard, which is compatible with Compaq COBOL for OpenVMS
VAX behavior

1

X/Open standard, which conforms to the X/Open CAE Specification: COBOL
Language
and which offers X/Open portability

Both effectively control potential conflicts of file access between simultaneously
running COBOL processes. Both offer locking for all file types: sequential,
relative, and indexed.

Note

If you choose X/Open standard file sharing and record locking for a file
connector, you must not use Compaq standard syntax anywhere in your
program for the same file connector. The two are mutually exclusive.

The Compaq COBOL compiler determines whether to apply X/Open standard
behavior or Compaq standard behavior for any file connector on the basis of
the syntax used for that file connector. The following syntax identifies X/Open
standard:

LOCK MODE (SELECT statement)
WITH LOCK (OPEN statement)
WITH [NO] LOCK (READ statement)
UNLOCK RECORDS

The following syntax identifies Compaq standard:

APPLY LOCK-HOLDING (Environment Division)
ALLOWING

1

REGARDLESS

1

(Procedure Division)

UNLOCK ALL

For any given file connector, any subsequent I-O locking syntax in your program
must be consistent: X/Open standard and Compaq standard file sharing/record
locking (implicit or explicit) cannot be mixed for the same file connector.

If a program includes any ambiguous semantics for I-O verbs (that is, no locking
syntax for verbs for which the two standards provide different default behavior)
and the previous code does not use Compaq or X/Open standard-specific syntax
for that file connector, the compiler determines which standard to use by applying
the specification (or default) from your compile command line, as follows:

The

-std [no]xopen

flag on the

cobol

command for the Tru64 UNIX

operating system

1

Some exceptions exist on Windows NT and Tru64 UNIX. See Compaq COBOL Reference
Manual
for details.

Sharing Files and Locking Records 8–3