COBOL Manual for TNS and TNS/R Programs

Disk Input and Output
HP COBOL Manual for TNS and TNS/R Programs522555-006
28-20
Reading a Queue File
Reading a Queue File
When you read a record of a queue file, you have a choice of:
Removing the Record From the Queue
Leaving the Record in the Queue
Removing the Record From the Queue
To read a record and remove it from the queue, use the READ ... NEXT WITH LOCK
statement. The compiler translates the READ ... NEXT WITH LOCK statement to a call
to the Guardian routine READUPDATELOCK[X].
Leaving the Record in the Queue
To read a record but leave it in the queue, use the READ ... NEXT statement (without
LOCK). The compiler translates the READ ... NEXT statement to a call to the Guardian
routine READ[X].
Writing to a Queue File
To write to a queue file, be sure that it exists and then open it for input and output; for
example:
OPEN queue-file I-O SHARED SYNCDEPTH 0
In the file-control entry, specify ACCESS MODE IS RANDOM.
After the file is open, use any form of the WRITE statement to write to it. The value that
you write to the timestamp field does not matter, because the system replaces that
value with its own timestamp.
Establishing Starting Points in Files
When you read a file using a key, you sometimes want to start at the record associated
with a given key value and continue to read successive records according to the value
of that key until you reach the record associated with a certain other value of that key.
The key can be the prime key of a file of relative or indexed organization or an
alternate key of any structured file.
Such a key is termed the key of reference. The mechanisms in HP COBOL that
implement this form of reading are the DYNAMIC access mode, the START statement,
and the sequential form of the READ statement (a READ statement with a NEXT
phrase).