Technical data

FETCH
5. The DBCS makes a copy of the selected database record available to the
program in the user work area. Any change made to the user work area
does not affect the record in the database. You must execute a MODIFY and
COMMIT statement to make permanent changes to the database.
6. Unless otherwise specified by the RETAINING clause (see Section 4.9.1,
RETAINING Clause), the successful FETCH statement causes the DBCS to
update these currency indicators to point to the selected record:
Run unit.
Realm.
Record type.
Set type. If it is an owner record type of the set type, this currency
indicator points to the selected record even if the set is empty. If it is a
member record type of the set type, this currency indicator points to the
selected record only if it is currently a member of some set of that record
type.
7. The DBCS places the database key of the fetched record in the special register
DB-KEY.
8. If a database exception condition occurs during the execution of a FETCH
statement, the DBCS places a database exception condition code in the
special register DB-CONDITION (see Technical Note). This code identifies
the condition.
9. [NOT]ON ERROR and [NOT]AT END cannot be used concurrently in a Fetch
statement.
10. If either AT END or ON ERROR is used, it must precede USE.
11. If ON ERROR and NOT ON ERROR are used concurrently in a Fetch
statement, USE procedures will not be activated.
Technical Note
FETCH statement execution can result in these database exception conditions
and those associated with the evaluation of the record selection expression:
DBM$_CONVERR A data conversion error occurred in the FETCH
operation.
DBM$_ILLNCHAR Invalid character found in a numeric field.
DBM$_NONDIGIT Nonnumeric character found in a numeric field.
DBM$_OVERFLOW A data overflow error occurred in the FETCH
operation.
DBM$_TRUNCATION A data truncation error occurred in the FETCH
operation.
DBM$_UNDERFLOW A data underflow error occurred in the FETCH
operation.
Additional References
Section 2.2, on reserved words (database special registers)
HP COBOL Reference Manual, Chapter 6, section on scope of statements
Section 4.6, on record selection expressions
HP COBOL Reference Manual, Chapter 6, section on AT END phrase
4–32 Procedure Division