Technical data
One currency indicator exists for each realm, set type, and record type defined
in your subschema. Another currency indicator, called the run-unit currency
indicator, also exists for the run unit.
All the currency indicators in a run unit are null prior to execution of the first
DML statement. The null value indicates there is neither a current record nor
a current position. Execution of certain DML statements can change the value
of currency indicators. However, currency indicators do not change if statement
execution fails.
The DBCS also uses currency indicators as place markers to control its sequence
of access to the database. For example, if VENDOR is the name of the vendor
records in Figure 5–2, then the current of VENDOR is normally the vendor record
most recently accessed. Likewise, in the set VENDOR_SUPPLY, the current of
VENDOR_SUPPLY is normally the most recently accessed record of that set.
Note that current of set could be either a member or owner record because both
record types are part of the VENDOR_SUPPLY set.
Failure to establish correct currency can produce incorrect or unpredictable
results. For example, you might unknowingly modify or delete the wrong record.
The following sections describe how the DBCS sets currency indicators and how
to use currency status in a DML program.
5.13.1 Current of Realm
Each realm currency indicator can be null or it can identify:
• A record and its position in the realm
• A position in the realm but not a specific record
A record identified by the realm currency is called current of realm. The DBCS
updates current of realm only when you reference a different record within the
realm. For example:
000100 PROCEDURE DIVISION.
000110 .
000120 .
000130 .
000500 FIND FIRST PART WITHIN BUY.
000510 FIND FIRST PART WITHIN MAKE.
000520 FIND NEXT PART WITHIN BUY.
000600 FIND NEXT SUPPLY WITHIN PART_INFO.
000610 .
000620 .
000630 .
For example, if LABEL and CASSETTE are in the BUY realm, while TAPE is
in the MAKE realm, statement 000500 sets the first occurrence of PART record
in realm BUY (LABEL) as current of realm BUY. Statement 000510 sets the
first occurrence of PART record in realm MAKE (TAPE) as current of realm
MAKE. Notice that current of realm BUY is still the record occurrence accessed
in statement 000500. Statement 000520 changes the current of realm BUY to
the next occurrence PART record in realm BUY (CASSETTE). Current of realm
MAKE remains the record accessed in statement 000510. Because the SUPPLY
record type is located in the MARKET realm, statement 000600 sets the current
of MARKET realm to the first SUPPLY record in the current PART_INFO set.
5–26 Database Programming with HP COBOL