Technical data

Example 8–1 (Cont.) Populating a Database
RESP-PART-LOOP.
MOVE PART_ID OF RESP-FOR-RECORD TO PART_ID OF PART.
FIND FIRST PART WITHIN ALL_PARTS USING PART_ID OF PART
AT END
DISPLAY PART_ID OF RESP-FOR-RECORD,
" PART_ID for RESPONSIBLE_FOR does not exist"
GO TO RESP-FOR-LOAD.
CONNECT PART TO RESPONSIBLE_FOR.
READ RESP-FOR-FILE AT END GO TO RESP-FOR-LOAD-END.
IF EMP_ID OF RESP-FOR-RECORD = EMP_ID OF EMPLOYEE
GO TO RESP-PART-LOOP
ELSE
GO TO RESP-FOR-LOAD-LOOP.
RESP-FOR-LOAD-END.
EXIT.
8.2 Backing Up a Database
The PARTSBACK program in Example 8–2 unloads all PARTS database records,
independently of their pointers, into a series of sequential data files. It is the first
step in restructuring and reorganizing a database. For example, after backing up
the database, you can change its contents. You can also create a new version of
the database including different keys or new set relationships.
The PARTS database consists of a NEW root file with a default extension of .ROO
describing the database instance and a series of .DBS storage files containing
the actual data records. PARTS is the schema relative to the current position in
CDD/Repository when the program is compiled. In the DB statement, PARTS and
NEW can be logical names. If PARTS is not a logical name, HP COBOL appends
PARTS to CDD$DEFAULT; for example, CDD$DEFAULT.PARTS. If NEW is not
a logical name, the DBCS appends .ROO as the default file type; for example,
NEW.ROO.
Example 8–2 Backing Up a Database
IDENTIFICATION DIVISION.
PROGRAM-ID. PARTSBACK.
*************************************************************
*
* This program unloads the PARTS database
*
*************************************************************
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
(continued on next page)
Database Programming Examples 8–9