HP COBOL DBMS Database Programming Manual Order Number: AA-Q6PGD-TE January 2005 This manual explains how to develop Oracle DBMS database programs with HP COBOL on the OpenVMS Alpha, OpenVMS I64, and the OpenVMS VAX operating systems. Revision/Update Information: This manual supersedes the COMPAQ COBOL DBMS Database Programming Manual. Operating System and Version: OpenVMS I64 Version 8.2 OpenVMS Alpha Version 6.2 or higher OpenVMS VAX Version 6.
© 2005 Copyright Hewlett-Packard Development Company, L.P. Confidential computer software. Valid license from HP required for possession, use, or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor’s standard commercial license. The information contained herein is subject to change without notice.
Contents Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix 1 Program Organization and Structure 1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.5 1.6 Program Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . HP COBOL Data Manipulation Language (DML) . . . . . . . Creating an HP COBOL DML Program . . . . . . . . . . . . . . . Compiling an HP COBOL DML Program . . . . . . . . . . . . .
.8 4.8.1 4.8.2 4.8.3 4.8.4 4.9 4.9.1 Programming for Database Exceptions and Error Handling . . . . . . . . . Database On Error Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . At End Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exception Conditions and the USE Statement . . . . . . . . . . . . . . . . . Translating DB-CONDITION Values to Exception Messages . . . . . . Database Programming Statements in the COBOL Procedure Division . COMMIT .
.13 Currency Indicators . . . . . . . . . . . . . . . . . . . . . . . . . . 5.13.1 Current of Realm . . . . . . . . . . . . . . . . . . . . . . . . . 5.13.2 Current of Set Type . . . . . . . . . . . . . . . . . . . . . . . 5.13.3 Current of Record Type . . . . . . . . . . . . . . . . . . . . 5.13.4 Current of Run Unit . . . . . . . . . . . . . . . . . . . . . . 5.14 Currency Indicators in an HP COBOL DML Program 5.14.1 Using the RETAINING Clause . . . . . . . . . . . . . . 5.14.2 Using Keeplists . . . . .
A COBOL Database Programming Reserved Words Glossary of Oracle DBMS-Related Terms Index Examples 4–1 4–2 5–1 5–2 5–3 5–4 6–1 6–2 6–3 6–4 6–5 6–6 7–1 7–2 7–3 7–4 7–5 7–6 8–1 8–2 8–3 8–4 8–5 8–6 8–7 8–8 A Single USE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . Multiple USE Statements . . . . . . . . . . . . . . . . . . . . . . . . . . Printing a Listing of a Simple Set . . . . . . . . . . . . . . . . . . . . Using Forked Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5–8 5–9 5–10 5–11 5–12 5–13 5–14 5–15 5–16 5–17 5–18 5–19 5–20 5–21 5–22 5–23 5–24 5–25 5–26 5–27 5–28 5–29 5–30 5–31 5–32 5–33 6–1 6–2 6–3 6–4 6–5 6–6 6–7 6–8 6–9 6–10 7–1 7–2 7–3 7–4 7–5 Set Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Occurrence Diagram of a Relationship Between Two Set Types . . . . . . Bachman Diagram of a System-Owned Set Type . . . . . . . . . . . . . . . . . Bachman Diagram of a Simple Set Type . . . . . . . . . . . . . . . . . . .
7–6 7–7 Split Screen After FETCH NEXT WITHIN PART_SUPPLY . . . . . . . . Split Screen After FETCH 2 WITHIN PART_SUPPLY . . . . . . . . . . . . 7–9 7–10 Tables 2–1 3–1 4–1 4–2 viii COBOL Database-Related User-Defined Words . . . . . . HP COBOL and DDL Utility Data Type Equivalences . Types of COBOL Statements . . . . . . . . . . . . . . . . . . . . Contents of COBOL Sentences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Preface This manual describes how to develop Oracle CODASYL DBMS database programs with HP COBOL on the OpenVMS Alpha, OpenVMS Industry Standard 64 (OpenVMS I64), or OpenVMS VAX operating system. It also contains information about HP COBOL language features specific to OpenVMS. The HP COBOL DBMS Database Programming Manual is a component of the HP COBOL documentation set. Complete information about HP COBOL can be found in the HP COBOL User Manual and HP COBOL Reference Manual.
Document Structure This manual is organized as follows: • Chapter 1, Program Organization and Structure, describes the structure and organization of an HP COBOL database program, and explains how you compile, link, and run your program. • Chapter 2, Database Programming Elements of HP COBOL, describes elements of the HP COBOL language that support database programming. • Chapter 3, Data Division, describes logical and physical concepts of the Data Division in relation to database programs.
Introduction to Oracle CODASYL DBMS Introduces the features of Oracle CODASYL DBMS and provides a summary of product components. It also supplies a documentation directory, a glossary, and a master index for the entire documentation set. Oracle CODASYL DBMS Database Administration Reference Manual Describes the syntax and function of the data definition language (DDL) used to write schemas, storage schemas, subschemas, and security schemas.
How to Order Additional Documentation For information about how to order additional documentation, visit the following World Wide Web address: http://www.hp.com/go/openvms/doc/order Conventions The following product names may appear in this manual: • HP OpenVMS Industry Standard 64 for Integrity servers • OpenVMS I64 • I64 All three names—the longer form and the two abbreviated forms—refer to the version of the OpenVMS operating system that runs on the Intel® Itanium® architecture.
Conventions Meaning The symbol CTRL/x indicates that you hold down the key labeled CTRL while you simultaneously press another key; for example, CTRL/C , CTRL/O . CTRL/x $ The dollar sign ( $ ) represents the OpenVMS system prompt.
1 Program Organization and Structure The fundamental elements of the COBOL language are described in the current ANSI standard and the HP COBOL basic documentation set. The elements specific to database programming have been collected and concentrated in this optional book for the convenience of programmers who write COBOL database programs. 1.1 Program Structure Figure 1–1 shows the basic structure of a COBOL program, which is organized in divisions, sections, paragraphs, sentences, and entries.
Figure 1–1 (Cont.) Structure of a COBOL Program DATA DIVISION. SUBSCHEMA SECTION. subschema entries and keeplist entries FILE SECTION. file and record description entries report file description entries sort-merge file and record description entries WORKING-STORAGE SECTION. record description entries LINKAGE SECTION. record description entries REPORT SECTION. report and report group description entries. SCREEN SECTION. (Alpha, I64) screen description entries (Alpha, I64) PROCEDURE DIVISION. DECLARATIVES.
Entries that begin with level-numbers are called data description entries. The level-number values are 01 to 49, 66, 77, and 88. Level-numbers 01 to 09 can be represented as one- or two-digit numbers. Level 01 and 77 data description entries begin in Area A. All other data description entries can begin anywhere to the right of Margin A. Indentation has no effect on level-number magnitude; it merely enhances readability. 1.
FETCH Locates a record in the database, retrieves its data item values, and places them in the user work area (UWA). FREE Releases references to records. GET Retrieves data item values of a previously located record and places them in the user work area (UWA). KEEP Remembers a record so you can later refer to it. Records can be found in several ways in the database.
1.4 Compiling an HP COBOL DML Program Your database administrator (DBA) creates schema and subschema definitions in Oracle CDD/Repository. These record definitions are defined in DMU format and are intended to serve all OpenVMS languages that might access them. In this format, the record definitions are not compatible with COBOL record definitions.
This file name may vary depending on the version of DBMS you are using. For example, if you are using DBMS Version 7.2, the command would be the following: $ LINK DMLPROG,SYS$LIBRARY:DBMDML72/OPT 1.6 Running an HP COBOL DML Program You use the DCL command RUN to execute your HP COBOL DML program. At run time, the Database Control System (DBCS) fills a variety of roles in HP COBOL.
2 Database Programming Elements of HP COBOL In your database programming project you will need familiarity with: • Database-related user-defined words • Database-related reserved words 2.1 Database-Related User-Defined Words A user-defined word is a COBOL word that you must supply to satisfy the format of a clause or statement. This word consists of characters selected from the set A to Z, 0 to 9, the currency sign ( $ ), underline ( _ ), and hyphen ( - ).
Table 2–1 COBOL Database-Related User-Defined Words User-Defined Word Set Purpose Keeplist-name Names a list of database keys used by the run unit to lock records for later use. Realm-name Names a database realm. (See the READY statement in the Procedure Division chapter.) Schema-name Names a database schema. (See the DB statement in the Data Division chapter.) Set-name Identifies a database set type. Sub-schema-name Names a database subschema. (See the DB statement in the Data Division chapter.
2.2.3 DB-CURRENT-RECORD-ID The reserved word DB-CURRENT-RECORD-ID names a database register. It consists of a word COMP item represented by PIC S9(4) USAGE IS COMP. The execution of COBOL data manipulation language (DML) statements that alter currency indicators causes the Database Control System (DBCS) to place a value in this register. If the currency indicator for the run unit is not null, the register contains the subschema User ID number (UID) of the record type of the current record of the run unit.
3 Data Division The logical and physical concepts that apply to the Data Division in any COBOL program also apply to your database programs. The HP COBOL Reference Manual presents the general formats for Data Division entries and clauses, describes their basic elements, and lists rules of use. Information of special interest to the database programmer will be found here. The Data Division defines the data processed by your COBOL program in both physical and logical terms.
3.1 DATA DIVISION General Format and Rules Function The Data Division describes data the program creates, receives as input, manipulates, and produces as output. General Format DATA DIVISION. 2 SUB-SCHEMA SECTION. 3 66 sub-schema-entry. 7 77 6 4 f keeplist-entry g . . . 5 2 FILE SECTION. 66 66 record-description-entry file-description-entry f g . . . ... 66 66 66 [ report-file-description-entry ] . . . 66 4 sort-merge-file-description-entry f record-description-entry g . . . . . .
Subschema Section 2. The Subschema Section names the subschema you want to use. It describes a logical view of the database as it is to be accessed by the COBOL program. It begins with the Subschema Section header containing the reserved words SUB-SCHEMA SECTION followed by a period ( . ) separator character. 3. The Subschema entry follows the Subschema Section header. 4.
Additional References Refer to the HP COBOL Reference Manual for: • REPORT clause • VALUE IS clause • CALL statement • User-defined words 3–4 Data Division
DB (Subschema Description) DB (Subschema Description) Function The Subschema entry allows a program to access a subschema in Oracle CDD/Repository under the schema name. General Format DB sub-schema-name WITHIN schema-name [ 2 FOR database-name ] 4 THRU THROUGH stream-name 3 5 . sub-schema-name references a subschema name in Oracle CDD/Repository under the schema name. See Technical Notes for more information. schema-name references a schema name in Oracle CDD/Repository.
DB (Subschema Description) 5. When you compile a program containing a DB statement, the resulting .OBJ file includes the subschema date and time stamp assigned to the sub-schemaname when it was inserted in Oracle CDD/Repository. At run time, the DBCS finds the root file and binds the program to the subschema identified by subschema-name.
DB (Subschema Description) Table 3–1 (Cont.
DB (Subschema Description) • You can use this Database Operator (DBO) utility command to display date and time stamp information on schema-name and sub-schema-name: $ DBO/REPORT Additional information is available with the HELP DBO/REPORT command.
LD (Keeplist Description) LD (Keeplist Description) Function The Keeplist Description entry names a keeplist. General Format LD keeplist-name [ LIMIT IS integer ] . keeplist-name is a user-defined name. integer is a positive integer. Syntax Rules 1. The LD entry can appear only in the Subschema Section following the DB entry or another LD entry. 2. The LIMIT clause is for documentation only. The compiler ignores this clause. General Rules 1. Keeplist-name implicitly has the global attribute.
LD (Keeplist Description) Additional Reference • Section 4.4, on database key identifiers Example The following example defines three keeplists to navigate through the PARTSS1 subschema: KEEP-COMPONENT, K-EMPLOYEE, and KL-ID: DB LD LD LD 3–10 Data Division PARTSS1 WITHIN PARTS. KEEP-COMPONENT. K-EMPLOYEE. KL-ID.
4 Procedure Division The Procedure Division of your COBOL database programs may contain declarative and nondeclarative procedures. These may include: • Directive and imperative statements • Conditional statements • Database key identifiers • Explicit and implicit scope terminators • Section 4.6, on record selection expressions 4.
Table 4–1 Types of COBOL Statements Type Verb Conditional COMMIT ([NOT] ON ERROR) CONNECT ([NOT] ON ERROR) DISCONNECT ([NOT] ON ERROR) ERASE ([NOT] ON ERROR) FETCH ([NOT] AT END or [NOT] ON ERROR) FIND ([NOT] AT END or [NOT] ON ERROR) FREE ([NOT] ON ERROR) GET ([NOT] ON ERROR) KEEP ([NOT] ON ERROR) MODIFY ([NOT] ON ERROR) READY ([NOT] ON ERROR) RECONNECT ([NOT] ON ERROR) ROLLBACK ([NOT] ON ERROR) STORE ([NOT] ON ERROR) Imperative COMMIT ( 1 ) CONNECT ( 1 ) DISCONNECT ( 1 ) ERASE ( 1 ) FETCH ( 2 ) FIND
sentences. The remaining text in this section discusses each type of statement and sentence in greater detail. Table 4–2 Contents of COBOL Sentences Type Contents of Sentence Imperative One or more consecutive imperative statements ending with a period Conditional One or more conditional statements, optionally preceded by an imperative statement, terminated by the separator period Compiler-Directing Only one compiler-directing statement ending with a period 4.1.
4.2 Explicit and Implicit Scope Terminators Scope terminators delimit the scope of some Procedure Division statements. Explicit scope terminators for database programs are as follows: END-COMMIT END-FIND END-READY END-CONNECT END-FREE END-RECONNECT END-DISCONNECT END-GET END-ROLLBACK END-ERASE END-KEEP END-STORE END-FETCH END-MODIFY Implicit scope terminators are as follows: • At the end of a sentence: the separator period. It terminates the scope of all previously unterminated statements.
Format 2—Keeplist Access ( OFFSET integer-exp FIRST LAST ) WITHIN keeplist-name General Rules Format 1 1. Record-name references a database record in the subschema. 2. Set-name references a database set in the subschema. 3. Realm-name references a subschema realm. 4. Use this format to select a record whose database key value is in a currency indicator. 5. The referenced currency indicator is the currency indicator for the record, set, or realm you specify in record-name, set-name, or realm-name. 6.
12. Integer-exp can be either an integer or an arithmetic expression. Both result in a longword integer value. 13. Using the FIRST clause is equivalent to OFFSET plus 1. It references the first database key value in the keeplist. 14. Using the LAST clause is equivalent to OFFSET minus 1. It references the last database key value in the keeplist. 15. The value of integer-exp points to an entry in keeplist-name.
4.5.1 Tenancy Conditions These conditions determine whether a record in the database is an owner, or member, or a tenant in one or more sets. General Format [ NOT ] [ 8 > > > < set-name ] > > > : OWNER MEMBER TENANT 9 > > > = > > > ; set-name is a subschema set name.
IF PART_USES EMPTY . . . IF EMPTY . . . If NOT is used, the result of the test is reversed. A database exception condition occurs if either: • The currency indicator for the run unit is null (DB-CONDITION is set to DBM$_CRUN_NULL). • The currency indicator for the run unit specifies a position (DB-CONDITION is set to DBM$_CRUN_POS). • The current record of run unit is not the owner of set-name (DB-CONDITION is set to DBM$_NOTOTYP). See Section 4.8.
• For the NULL condition, the referenced currency indicator points to a vacant position in the database or collection: Realm currency indicator (DB-CONDITION is set to DBM$_CRELM_ POS). Set currency indicator (DB-CONDITION is set to DBM$_CSTYP_POS). Run-unit currency indicator (DB-CONDITION is set to DBM$_CRUN_ POS). See the USE statement for more information on USE FOR DB-EXCEPTION. 4.5.4 Condition Evaluation Rules Parentheses can specify the evaluation order in complex conditions.
General Formats Format 1—Database Key Identifier Access This format selects a record by a database key value held by the Database Control System (DBCS) in a currency indicator or a keeplist entry. database-key-identifier database-key-identifier identifies a record according to the rules of database key identifiers. (See Section 4.4, Database Key Identifiers for more information.) For example: FIND CURRENT WITHIN PART-REC Format 2—Set Owner Access This format selects the record that owns a set.
bool-alternate [ OR bool-alternate ] . . . bool-alternate: simple-bool-relation [ AND simple-bool-relation ] ...
simple-bool-relation is a simple-condition (bool-condit), an expression, or the negation of either. bool-condition is a relation involving two operands joined by a relational operator.
3. If you use neither WITHIN realm-name nor WITHIN set-name, all records defined in the subschema make up the object collection. The object currency indicator defaults to the currency indicator for the run unit. The ordering of the object collection is unspecified. Qualification Clause Use record-name to restrict the search to records of a particular type. If you do not use record-name, the DBCS searches each record type in the subschema.
7. Using the PRIOR clause is equivalent to using RELATIVE –1. It refers to the record in the object collection immediately before the current position. 8. If you use int-exp without the RELATIVE clause, the DBCS selects the record whose ordinal position in the object collection is equal to int-exp. • If int-exp is positive, the ordinal position is relative to the first record of the object collection. • If int-exp is negative, the ordinal position is relative to the last record of the object collection.
4.7 Set Membership Options and DML Verbs The HP COBOL data manipulation language (DML) verbs CONNECT, DISCONNECT, ERASE, MODIFY, RECONNECT, and STORE can affect a record’s set membership. The effects of these verbs depend on the INSERTION and RETENTION clauses declared for the record’s membership in each set in the schema.
The NOT ON ERROR phrase allows execution of an imperative statement when a database exception condition does not occur. The format is as follows: [ NOT ] ON ERROR stment Stment is an imperative statement. When a database exception condition occurs and the statement contains an ON ERROR phrase: 1. The imperative statement associated with the ON ERROR phrase executes. 2. The NOT ON ERROR phrase, if specified, is ignored. 3.
. . . PROCESS-EXCEPTION. DISPLAY "Database Exception Condition Report". DISPLAY " ". DISPLAY "DB-CONDITION = ", DB-CONDITION WITH CONVERSION. DISPLAY "DB-CURRENT-RECORD-NAME = ", DB-CURRENT-RECORD-NAME. DISPLAY "DB-CURRENT-RECORD-ID = ", DB-CURRENT-RECORD-ID WITH CONVERSION. DISPLAY " ". CALL "DBM$SIGNAL". STOP RUN. 4.8.2 At End Condition An at end condition occurs when a program detects the end of a file.
4.8.3 Exception Conditions and the USE Statement Planning for exception conditions is an effective way to increase program and programmer productivity. A program with USE statements is more flexible than a program without them. They minimize operator intervention and often reduce or eliminate the time you need to debug and rerun the program. The USE statement traps unsuccessful run-time Oracle CODASYL DBMS exception conditions that cause the execution of a Declaratives procedure.
A Format 2 declarative executes whenever a database exception condition occurs and the corresponding DBM$_exception-condition is not explicitly stated in any Format 1 USE statement. Example 4–2 Multiple USE Statements PROCEDURE DIVISION. DECLARATIVES. 200-DATABASE-EXCEPTIONS SECTION. USE FOR DB-EXCEPTION ON DBM$_CRELM_NULL, DBM$_CRTYPE_NULL. 200-DATABASE. PERFORM 300-REPORT-DATABASE-EXCEPTIONS. IF DB-CONDITION = ..... GO TO ... IF DB-CONDITION = ..... GO TO ... STOP RUN. 225-DATABASE-EXCEPTIONS SECTION.
4.
COMMIT COMMIT Function The COMMIT statement ends your database transaction, makes permanent all changes made to the database since the last quiet point, and establishes a new quiet point for this run unit. General Format COMMIT [ STREAM stream name [ ON ERROR stment [ NOT ON ERROR stment2 [ END-COMMIT ] [ RETAINING {retaining list} ] ] ] ] stment is an imperative statement executed for an on error condition. stment2 is an imperative statement executed for a not on error condition.
COMMIT • Makes visible any changes you made to the database • Maintains READY modes for each target realm 6. If a database exception condition occurs during the execution of a COMMIT statement, the DBCS places a database exception condition code in the special register DB-CONDITION. This code identifies the condition. Additional References • Section 2.2 on reserved words (database special registers) • HP COBOL Reference Manual, Chapter 6, section on scope of statements • Section 4.8.
CONNECT CONNECT Function The CONNECT statement inserts the current record of the run unit as a member record into one or more sets. The set occurrence for each insertion is determined by the currency indicator for the corresponding set type. General Format CONNECT [ record-name 2 28 66 > > 66 > > > 66 > > 6 > 66 66 < 66 RETAINING 66 > > 66 66 > > > > > 6 4 > : 4 [ [ ON ERROR stment END-CONNECT ] TO { set-name } . . . ALL REALM RECORD 8 > < SET [ set-name ] . . . > : f set-name g . . .
CONNECT General Rules 1. The current record of the run unit must be in a realm in ready update mode and all records required by the Database Control System (DBCS) to execute the CONNECT statement must be in a realm in available mode. The CONNECT statement uses the current record of the run unit. 2. Use record-name to check that the current record of the run unit is a record type identical to the record-name record type. 3. The current record of the run unit must not already be a member of set-name. 4.
CONNECT DBM$_WRONGRTYP DBM$_NOT_MTYP DBM$_NOW_MBR DBM$_CSTYP_NULL DBM$_DUPNOTALL DBM$_NOT_UPDATE DBM$_CHKMEMBER The record type of record-name is not the same as the current record’s type. The current record is not a member record type of a set in the TO set-name phrase. The current record is already a member of the set specified in the TO set-name phrase. There is no current of set type for the set specified in the TO set-name phrase. This occurs only if the set is not a singular set.
DISCONNECT DISCONNECT Function The DISCONNECT statement logically removes the current record of the run unit from one or more sets. General Format ( DISCONNECT [ record-name ] [ ON ERROR stment [ NOT ON ERROR stment2 [ END-DISCONNECT FROM f set-name g . . . ALL ) ] ] ] record-name names a subschema record type. set-name names a subschema set type. stment is an imperative statement executed for an on error condition. stment2 is an imperative statement executed for a not on error condition.
DISCONNECT member are ignored. The current record of the run unit is removed from each remaining set type. 8. If the set type currency indicator for a disconnected set pointed to the current record, that currency indicator now points to the position in the set vacated by the record. All other currency indicators are not affected. 9. If the execution of a DISCONNECT statement results in a database exception condition, no changes are made to the membership of the current record in the database. 10.
ERASE ERASE Function The ERASE statement deletes the current record of the run unit from the database. Additional records owned by the current record may also be deleted and/or disconnected. General Format ERASE [ ALL ] [ record-name ] [ ON ERROR stment [ NOT ON ERROR stment2 [ END-ERASE ] ] ] record-name names a subschema record type. stment is an imperative statement executed for an on error condition. stment2 is an imperative statement executed for a not on error condition. General Rules 1.
ERASE 10. The successful ERASE statement changes currency indicators as follows: • The currency indicator for the current record of the run unit points to the position in the database vacated by the current record of the run unit. However, you no longer have a current record. • If an erased record is the current record of a disconnected set type, that set type currency indicator now points to the position in the set vacated by that record.
ERASE 2. This example has the same effect as in example 1 for each PART record that the CLASS1 record owns; however, it also erases the CLASS1 record. ERASE ALL CLASS1. Note Because CLASS1 has MANDATORY members, you cannot erase only CLASS1.
FETCH FETCH Function The FETCH statement is a combined FIND and GET that establishes a specific record in the database as the current record of the run unit and makes the record available to the run unit in the user work area. General Format FETCH database-record [ FOR UPDATE ] 2 28 66 > 66 > > > 66 66 < 66 RETAINING 6 > n 64 > > > : 46 2 66 4 [ 8 > <[ > :[ AT END stment REALM RECORD SET [ set-name ] . . . { set-name } . . .
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.
FETCH • Section 4.8.1, on database On Error condition • Section 5.14.1, on RETAINING clause • USE statement Examples 1. Currency indicator access. To retrieve the: • Current record of the run unit FETCH CURRENT. • Current record of the MAKE realm FETCH CURRENT WITHIN MAKE. • Current record of the CLASS_PART set FETCH CURRENT WITHIN CLASS_PART. • Current PART record FETCH CURRENT WITHIN PART. 2. Keeplist access. To retrieve the: • First entry in the keeplist FETCH FIRST WITHIN KEEPLIST-A.
FETCH • Record relative to the current record, this statement starts from the current position to the position defined by this offset FETCH RELATIVE SEARCH-NUMBER ON ERROR PERFORM 300-FETCH-IN-ERROR-ROUTINE END-FETCH. • PART record with PART_STATUS equal to ‘‘G’’ from the CLASS_PART set MOVE "G" TO PART_STATUS. FETCH NEXT CLASS WITHIN ALL_CLASS. FETCH NEXT PART WITHIN CLASS_PART USING PART_STATUS AT END . . . • DB-KEY access.
FIND FIND Function The FIND statement locates a specific record in the database and establishes it as the current record of the run unit. The FIND ALL statement locates zero or more records in the database and inserts them into the named keeplist. General Formats Format 1 FIND database-record [ FOR UPDATE 2 28 66 > > 66 > > > 66 > < 6 ( 66 RETAINING 66 66 66 > > > > > 6 4 > : 4 2 66 4 [ 8 > <[ > :[ END-FIND AT END stment ] REALM RECORD SET [ set-name ] . . . { set-name } . . .
FIND keeplist-name names a list of database keys used by a run unit to lock records for later reference. record-name names a subschema record type. realm-name names a subschema realm. rec-key is a key data item within the subschema record occurrence. bool-expres is a conditional expression that involves data items of the object record. General Rules Format 1 1. database-record must reference a record stored in a realm that is in ready mode. 2.
FIND All Formats 12. If a database exception condition occurs during the execution of a FIND statement, the DBCS places a database exception condition code in the special register DB-CONDITION (see Technical Note). This code identifies the condition. 13. The DBCS places the database key of the record found in the special register DB-KEY. 14. [NOT]ON ERROR and [NOT]AT END cannot be used concurrently in a Find statement. 15. If either AT END or ON ERROR is used, it must precede USE. 16.
FIND • First entry in the keeplist FIND FIRST WITHIN KEEPLIST-A. • Last entry in the keeplist FIND LAST WITHIN KEEPLIST-B. • N(th) entry in the keeplist FIND OFFSET RECORD-COUNT WITHIN KEEPLIST-C. 3. Set owner access. To locate the owner (PART) of the PART_USES set: FIND OWNER WITHIN PART_USES. 4. Record search access.
FREE FREE Function The FREE statement empties selected keeplists or removes a database key value from a keeplist or currency indicator. General Format 8 > > > < FREE > > > : database-key-id 2 ALL 4 FROM { keeplist-name } . . . CURRENT [ ON ERROR stment [ NOT ON ERROR stment2 [ END-FREE 3 5 9 > > > = > > > ; ] ] ] database-key-id represents a database key identifier. References are made to a keeplist entry or a currency indicator according to the rules for Database Key Identifiers.
FREE Technical Note FREE statement execution can result in these database exception conditions and those associated with a Database Key Identifier: DBM$_BADZERO DBM$_END Integer-exp is zero. You accessed a keeplist with fewer entries than you expected. Additional References • Section 2.2, on reserved words (database special registers) • HP COBOL Reference Manual, Chapter 6, section on scope of statements • Section 4.4, on database key identifiers • Section 4.8.
GET GET Function The GET statement moves the contents of the current database record of the run unit to your user work area. General Format GET h record-name { record-item } . . . i [ ON ERROR stment [ NOT ON ERROR stment2 [ END-GET ] ] ] record-name names a subschema record type. record-item is a group or elementary data item in a subschema record type. Record-item may be qualified. stment is an imperative statement executed for an on error condition.
GET 7. If a database exception condition occurs during the execution of a GET statement, the DBCS places a database exception condition code in the special register DB-CONDITION (see Technical Note). This code identifies the condition.
KEEP KEEP Function The KEEP statement inserts a database key value from a currency indicator or keeplist into a keeplist. General Format KEEP [ database-key-id ] USING destination-keeplist [ ON ERROR stment [ NOT ON ERROR stment2 [ END-KEEP ] ] ] database-key-id represents a database key identifier. References are made to a keeplist entry or a currency indicator according to the rules for Database Key Identifiers.
KEEP • Section 4.4, on database key identifiers • Section 4.8.1, on database On Error condition • USE statement Examples 1. Currency indicator access • To insert the database key value of the current record of the run unit into KEEPLIST-A: KEEP CURRENT USING KEEPLIST-A. • To insert the database key value of the current record of the CLASS_ PART set into KEEPLIST-B: KEEP CURRENT WITHIN CLASS_PART USING KEEPLIST-B.
MODIFY MODIFY Function The MODIFY statement changes the contents of specified data items in a database record. General Format MODIFY h record-name { record-item } . . . 2 28 66 > 66 > > > 66 66 < 66 RETAINING 6 > n 64 > > > 46 : i REALM RECORD SET [ set-name ] . . . { set-name } . . . [ ON ERROR stment [ NOT ON ERROR stment2 [ END-MODIFY 93 > > > > 777 = 77 CURRENCY o > > > > 57 ; 3 77 77 77 75 ] ] ] record-name names a subschema record type.
MODIFY 2. The DBCS changes the contents of the entire database record: • If you specify record-name • If you specify neither record-name nor record-item 3. Using record-item limits the changes to the database record to only those items you specify. 4. If you modify any data item that is the sort key for that record’s position in a sorted set, the DBCS automatically repositions the record in that set in accordance with the set-ordering criteria of the set type.
MODIFY DBM$_DUPNOTALL DBM$_NOT_UPDATE DBM$_CHKITEM DBM$_CHKMEMBER DBM$_CHKRECORD DBM$_CONVERR DBM$_ILLNCHAR DBM$_NONDIGIT DBM$_OVERFLOW DBM$_TRUNCATION DBM$_UNDERFLOW A sort key data item is modified creating a duplicate value in a DUPLICATES NOT ALLOWED set. A realm is not in ready update usage mode. A modified data item failed to pass the schema CHECK ITEM condition. A modified data item failed to pass the schema CHECK MEMBER condition.
MODIFY DISPLAY "ENTER PART DESCRIPTION - X(50): " WITHOUT ADVANCING. ACCEPT PART_DESC. . . . MODIFY PART ON ERROR DISPLAY "ERROR MODIFYING PARTS_RECORD . . . " PERFORM 200-PARTS-RECORD-ERROR-ROUTINE. GO TO 150-UPDATE-PARTS-RECORD. 2. In this example, PART_ID in the PART record is modified. PART_ID is a sort key for the CLASS_PART set. This routine will retain the current position in the CLASS_PART set after you modify the record. 300-FIX-ID-ROUTINE.
READY READY Function The READY statement begins a database transaction, prepares one or more database realms for processing, and places each specified realm in a ready mode. General Format READY [ realm-name ] . . .
READY 3. If you do not specify a realm-name, the DBCS (Database Control System) readies all realms in your subschema except those already readied. 4. The USAGE-MODE phrase establishes run-time privileges for this run unit. It also affects other run units running concurrently. It consists of two parts: ( a ) the allow mode, and ( b ) the access mode. 5. If the program does not specify a usage mode, PROTECTED RETRIEVAL is the default. 6.
READY 18. Figure 4–1 summarizes the effects of the allow and access options on concurrent run units readying the same realm-name. A database exception condition will occur if a concurrent run unit has a realm-name readied in a conflicting or incompatible mode (see Technical Notes). The First Run Unit column refers to a READY statement that has already been executed in a concurrent run unit. The Second Run Unit column refers to a READY statement being attempted by the current run unit.
READY DBM$_AREABUSY Your usage mode conflicts with another run unit’s usage mode. See Figure 4–1. Additional References • HP COBOL Reference Manual, Chapter 6, section on scope of statements • Section 4.8.1, on database On Error condition Example Depending on the contents of PROCESS-MODE, this statement readies the BUY, MAKE, and PERSONNEL realms in either PROTECTED UPDATE mode or CONCURRENT RETRIEVAL mode (default for USAGE-MODE).
RECONNECT RECONNECT Function The RECONNECT statement moves the current database record of the run unit from one set to another (possibly the same) set. General Format RECONNECT [ record-name ] WITHIN 2 28 66 > > 66 > > > 66 > < 6 ( 66 RETAINING 66 66 66 > > > > > 6 4 > : 4 [ ON ERROR stment [ NOT ON ERROR stment2 [ END-RECONNECT { set-name } . . . ALL REALM RECORD SET [ set-name ] . . . { set-name } . . .
RECONNECT 4. For each set-name you specify in the WITHIN clause: a. The DBCS disconnects the current record of the run unit from the set in which it is currently a member and inserts this record in the current set of the set-name set type. b. The position where the DBCS inserts the record into the set is determined by the set-ordering criteria defined in the schema for set-name. 5. If the program specifies the ALL option: a.
RECONNECT DBM$_NOT_UPDATE DBM$_NOT_MBR DBM$_CHKMEMBER The realm is not in ready update usage mode. You attempted to reconnect a record to a set in which it is not a member. The Oracle CODASYL DBMS CHECK (member) condition was evaluated to be false. The database has not been changed. Additional References • Section 2.2, on reserved words (database special registers) • HP COBOL Reference Manual, Chapter 6, section on scope of statements • Section 4.8.1, on database On Error condition • Section 5.14.
RECONNECT AFTER TERMINALS SUPPORTED TERMINALS NOT SUPPORTED VT1 VT3 VT4 VT2 ZK−6155−GE 4–56 Procedure Division
ROLLBACK ROLLBACK Function The ROLLBACK statement ends your database transaction, nullifies all database changes made by this run unit since its last quiet point, and establishes a new quiet point for this run unit. General Format ROLLBACK [ STREAM ] [ ON ERROR stment [ NOT ON ERROR stment2 [ END-ROLLBACK ] ] ] stment is an imperative statement executed for an on error condition. stment2 is an imperative statement executed for a not on error condition. Syntax Rules 1.
ROLLBACK 9. If a database exception condition occurs during the execution of a ROLLBACK statement, the DBCS places a database exception condition code in the special register DB-CONDITION. This code identifies the condition. Additional References • Section 2.2, on reserved words (database special registers) • HP COBOL Reference Manual, Chapter 6, section on scope of statements • Section 4.8.1, on database On Error condition • USE statement (USE FOR DB-EXCEPTION) • Section 5.2.
STORE STORE Function The STORE statement stores a new record in the database, establishes the record as an owner of an empty set of each set type for which the record is an owner record type, and connects the record as a member to the current set of each set type for which the record is an AUTOMATIC member record type. General Format STORE record-name [ NEXT TO ] DBKEY 2 28 66 > > 66 > > > 66 > < 6 ( 66 RETAINING 66 66 66 > > > > > 6 4 > : 4 [ WITHIN { realm-name } . . .
STORE If you do not specify the WITHIN option, the DBCS stores a new record occurrence in one valid subschema realm for that record type. 3. If you specify the DBKEY option, the target area is determined by page size. If the page specified by the DB-KEY special register has space available, that page is the target area. Otherwise, the DBCS chooses the next page that has available space. 4. After a successful STORE operation, the DB-KEY special register contains the database key for the record. 5.
STORE DBM$_CHKITEM DBM$_CHKMEMBER DBM$_CHKRECORD DBM$_CSTYP_NULL DBM$_CONVERR DBM$_ILLNCHAR DBM$_NONDIGIT DBM$_OVERFLOW DBM$_TRUNCATION DBM$_UNDERFLOW DBM$_SETSELECT A record-name item contains an invalid value as determined by a schema CHECK clause. A record-name item contains an invalid value as determined by a schema CHECK clause. A record-name item contains an invalid value as determined by a schema CHECK clause.
USE USE Function The USE statement specifies Declaratives procedures to handle file input/output errors and database exception conditions. It can also specify procedures to be executed before the program processes a specific report group. These procedures supplement the procedures in the COBOL Run-Time System and RMS. USE is part of the COBOL ANSI standard. Formats 1 and 2 Refer to the HP COBOL Reference Manual for Formats 1 and 2. Only Format 3 is applicable to DBMS DML.
USE General Rules All Formats 1. At run time, two special precedence rules apply for the selection of a USE procedure when a program is contained within another program. In applying these rules, only the first qualifying USE procedure is selected for execution. The order of precedence for the selection of a USE procedure is as follows: • First, select the USE procedure within the program containing the statement that caused the qualifying condition.
USE 11. A database USE procedure executes for a COBOL DML statement’s exception condition: ( a ) if the OTHER phrase is the only phrase specified in the program, and ( b ) if these conditions are also true: • The COBOL DML statement has no ON ERROR phrase • The COBOL DML statement has no AT END phrase • The program does not specify an ON phrase for that exception condition After the USE procedure executes, control returns to the next executable statement in the invoking routine, if one is defined.
USE Technical Notes • If this program has an exception condition when executing a READY statement, or if the program does not ready the database before executing a DML statement, 210-DATABASE-EXCEPTIONS executes. • If any other database exception condition occurs during program execution, 200-DATABASE-EXCEPTIONS executes.
4.9.1 RETAINING Clause The RETAINING clause specifies which currency indicators are not updated during the execution of the COMMIT, CONNECT, FETCH, FIND, MODIFY, RECONNECT, and STORE statements. General Format 2 66 66 66 66 66 66 46 28 > > 66 > > > > 66 > > > > 66 < RETAINING 6 66 > > > > 66 > > > > > 4: > REALM RECORD 8 > < SET [ set-name ] . . . > : [ set-name ] . . .
5 Database Programming with HP COBOL With HP COBOL database programming you can access data without designing separate files for specific applications. You accomplish this with the database management system (Oracle CODASYL DBMS) and the COBOL data manipulation language (DML).
where: nodename names the new node in the CDD to contain your personal PARTS database. defaultname is your CDD default. For example: $ RUN SYS$SYSTEM:DMU RET DMU> CREATE DEMONODE RET DMU> SHOW DEFAULT RET CDD$TOP DMU> EXIT RET $ 2. Define CDD$DEFAULT using the defaultname, a period, and the nodename from step 1. For example: $ DEFINE CDD$DEFAULT "CDD$TOP.DEMONODE" defaultname separator period nodename ZK−1434A−GE As of Version 7.
5.2.1 Database A database is a collection of your organization’s data gathered into a number of logically related units. The database administrator (DBA) and representatives from user departments decide on the organization’s informational needs. After these individuals agree on the contents of the database, the DBA assumes responsibility for designing, creating, and maintaining the database. 5.2.2 Schema The schema is a program written by the DBA using DDL statements.
IDENTIFICATION DIVISION. PROGRAM-ID. MULTI-STREAM-1. DATA DIVISION. SUB-SCHEMA SECTION. DB PARTS1 WITHIN PARTS FOR "NEW.ROO" THRU STREAM-1. . . . CALL MULTI-STREAM-2 . . . END PROGRAM MULTI-STREAM-1. IDENTIFICATION DIVISION. PROGRAM-ID. MULTI-STREAM-2. DATA DIVISION. SUB-SCHEMA SECTION. DB DEFAULT_SUBSCHEMA WITHIN PARTS FOR "NEW.ROO" THRU STREAM-2. . . . CALL MULTI-STREAM-3. EXIT PROGRAM. IDENTIFICATION DIVISION. PROGRAM-ID. MULTI-STREAM-3. DATA DIVISION. SUB-SCHEMA SECTION.
5.4 Database Records A database record, like a record in a file, is a named collection of elementary database data items. Records appear in the database as record occurrences. Oracle CODASYL DBMS records are linked into sets. In HP COBOL database applications, you do not describe database records in the COBOL program. Rather, you must use the DB statement to extract and translate subschema record definitions into your COBOL program as COBOL record definitions.
5.8 Set Types A set type is a named relationship between two or more record types. The major characteristic of a set type is a relationship that relates one or more member records to an owner record. The owner and members of a set are called tenants of the set. For example, the PART record type could own a SUPPLIER record type in the set PART_INFO. As with records, the DBA describes set types in the schema; set occurrences exist in the database. The unqualified term set implies set occurrence.
3. VENDOR record type: MUSICO INC., SOUND-OFF CO. Note All occurrence diagrams display member records within a set in counterclockwise order.
Figure 5–4 Sample Occurrence Diagram 1 PART_INFO SET CASSETTE 1−MONTH LABEL 4−DAYS TAPE 2−WEEKS 2−DAYS 5−DAYS 1−WEEK VENDOR_SUPPLY SET MUSICO, INC. 2−WEEKS SOUND−OFF CO.
Figure 5–5 Sample Occurrence Diagram 2 SOUND−OFF CO LABEL 4−DAYS CASSETTE 2−WEEKS MUSICO, INC. 1−MONTH 2−DAYS 1−WEEK 5−DAYS TAPE PART_INFO SET VENDOR RECORD TYPE VENDOR_SUPPLY SET PART RECORD TYPE SUPPLY RECORD TYPE ZK−1483−GE 5.9 Sets Sets are the basic structural units of a database. A set occurrence has one owner record occurrence and zero, one, or several member record occurrences.
Figure 5–6 One Occurrence of Set PART_SUPPLY PART_SUPPLY PART A S−1 S−7 ZK−1484−GE The DBA can specify a set type where each PART record occurrence can own SUPPLY record occurrences. Figure 5–7 is a Bachman diagram that shows the relationship between PART record types and SUPPLY record types. Bachman diagrams give you a picture of the schema or a portion of the schema. Each record type is enclosed in a box.
Figure 5–8 Set Relationships PART VENDOR PART_SUPPLY VENDOR_SUPPLY SUPPLY ZK−1486−GE Figure 5–9 Occurrence Diagram of a Relationship Between Two Set Types PART_SUPPLY VENDOR_SUPPLY GASKET 500 U.S. SEALS 100 EASTERN GASKETS 750 SEAL−TITE ZK−1487−GE 5.9.1 Simple Set Relationships A simple set relationship contains one owner record type and one or more member record types.
Figure 5–10 Bachman Diagram of a System-Owned Set Type SYSTEM ALL_PARTS PART ZK−1488−GE 5.9.1.2 Simple Sets In simple sets, each set contains only one type of member record. Figure 5–11 is a Bachman diagram of a simple set type where similar parts are grouped by class code. For example, plastic parts could be member records owned by a class record with a class code PL.
Example 5–1 prints a listing of all parts with a class code of PL. Example 5–1 Printing a Listing of a Simple Set PROCEDURE DIVISION. . . . 100-GET-PLASTICS-CLASS. MOVE "PL" TO CLASS_CODE FIND FIRST CLASS USING CLASS_CODE. 200-GET-PLASTICS-PARTS. FETCH NEXT PART WITHIN CLASS_PART AT END GO TO 900-DONE-PLASTIC-PARTS. ***************************************************** * Plastic parts print routine. ***************************************************** GO TO 200-GET-PLASTICS-PARTS. 5.9.1.
Example 5–2 Using Forked Sets PROCEDURE DIVISION. . . . 100-GET-PART. DISPLAY "TYPE PART ID". ACCEPT PART_ID. IF PART_ID = "DONE" GO TO 900-DONE-PART-INQUIRY. FETCH FIRST PART USING PART_ID ON ERROR DISPLAY "PART " PART_ID " NOT IN DATABASE" GO TO 100-GET-PART. 200-GET-SUPPLY-INFO. FETCH NEXT SUPPLY WITHIN PART_INFO AT END FETCH OWNER WITHIN PART_INFO GO TO 300-GET-QUOTE-INFO. ***************************************************** * The FETCH OWNER statement resets currency to * * point to the owner.
Figure 5–13 Forked Set Occurrence PART_INFO PART SUPPLY PR_QUOTE PR_QUOTE PR_QUOTE SUPPLY ZK−1491−GE 5.9.2 Multiset Relationships A set cannot contain an owner record and a member record of the same type. Nor can a simple set represent a many-to-many relationship. To simulate such relationships, Oracle CODASYL DBMS uses the concept of multiset relationships. Multiset relationships occur when two set types share a common record type called a junction record.
Figure 5–14 Bachman Diagram of a Many-to-Many Relationship Between Two Types of Records PART PART_INFO VENDOR VENDOR_SUPPLY SUPPLY ZK−1492−GE Figure 5–15 is an occurrence diagram of a many-to-many relationship between two types of records. This diagram typifies a many-to-many relationship because it shows a part (TAPE) being supplied by more than one vendor and a vendor (SOUND-OFF CO.) supplying more than one part.
Figure 5–15 Many-to-Many Relationship Between Two Types of Records SOUND−OFF CO CASSETTE 1−MONTH 1−WEEK 5−DAYS 2−DAYS Musico, Inc. TAPE VENDOR RECORD TYPE PART_SUPPLY SET PART RECORD TYPE SUPPLY RECORD TYPE VENDOR_SUPPLY SET ZK−1493−GE 5.9.2.2 Many-to-Many Relationships Between Records of the Same Type To represent a relationship between record occurrences of the same type, the DBA builds a many-to-many relationship using member records to create the necessary links.
Figure 5–16 Bachman Diagram of a Many-to-Many Relationship Between Records of the Same Type PART PART_USES PART_USED_ON COMPONENT ZK−1494−GE For example, assume you are creating a bill of materials and you have a finished part, a stool, made from one stool seat and four stool legs. Figure 5–17, Figure 5–18, Figure 5–19, and Figure 5–20 show occurrence diagrams of the bill of materials you would need to build a stool.
Figure 5–18 Retain PART_USES Currency STOOL (CURRENT OF PART_USES) STOOL SEAT (CURRENT OF PART_USED_ON) ZK−1496−GE 3. Build a COMPONENT record (component 1), and store it retaining PART_ USES currency. Because COMPONENT participates in the PART_USES set, storing it normally changes the set’s currency. Therefore, executing a STORE statement with the retaining clause keeps STOOL as current of PART_USES.
Figure 5–20 Finding the Stool Legs While Keeping STOOL Current of PART_ USES STOOL (CURRENT OF PART_USES) COMPONENT 1 STOOL LEGS STOOL SEAT (CURRENT OF PART_USED_ON) ZK−1498−GE 5. Build a second COMPONENT record (component 4) and store it. This links both PART_USES owner STOOL and PART_USED_ON owner STOOL LEGS to component 4. This completes all the necessary relationships you need to create the bill of materials shown in Figure 5–21. 500-CONNECT-COMPONENT-4. MOVE 4 TO COMP_QUANTITY. STORE COMPONENT.
Figure 5–22 Occurrence Diagram of a Many-to-Many Relationship Between Records of the Same Type PART A B C PART_USES D PART_USED_ON 1 COMPONENT 4 2 3 5 PART_USES PART_USED_ON ZK−1500−GE The STOOL program in Example 8–5 loads and connects the parts for the STOOL bill of materials presented earlier in this section. It uses the relationship represented in Figure 5–16 to print its parts breakdown report in Section 8.6. Figure 5–23 explains how to read the parts breakdown report.
5.9.2.3 One-to-Many Relationships Between Records of the Same Type To build a one-to-many relationship between records of the same type, the DBA uses junction records. In a one-to-many relationship between records of the same type, either record type can be the junction record. However, in Figure 5–24 the WK_GROUP record type serves as the junction record because the EMPLOYEE record type has most of the relationship’s data. The record type EMPLOYEE includes all employees—supervisors, managers, and so forth.
The data in Figure 5–25 shows sample EMPLOYEE records and the connecting WK_GROUP links (Groups A, B1, and B2). For example, employee Howell manages a group that consists of employees Noyce and Moore.
Figure 5–26 Sample Data After Update 10500 HOWELL MANAGES GROUP A CONSISTS_OF 08400 NOYCE 05000 KLEIN 06600 MOORE MANAGES MANAGES MANAGES GROUP B1 GROUP B3 GROUP B2 CONSISTS_OF CONSISTS_OF CONSISTS_OF 01000 RAVAN 04000 BURLEW 07000 NEILS 01400 RILEY 02000 DEANE 05500 BAKER 07400 FIFER ZK−1503−GE Example 8–6 (PERSONNEL-UPDATE program) uses the data in Figure 5–25 and shows you how to: 1. Load the database (PERSONNEL-UPDATE). 2.
5.11 Realms A realm is a group of one or more areas. Realms are logical divisions of the database. A realm is the object of the DML READY statement. Figure 5–27 shows the relationship between the schema, areas, subschema, and realms. Even though realms can contain data from more than one area, the type of data they contain is dependent on the subschema. It acts as a filter, allowing access to only specific data items.
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.
5.13.2 Current of Set Type Each set type currency indicator can be null or it can identify: • A record and its position in the set type • A position in the set type but not a record A record identified by a set type currency indicator is the current record for the set type, or current of set type. If the ordering criterion for a set type is NEXT or PRIOR, the set type’s currency indicator specifies the insertion point for member records.
000100 PROCEDURE DIVISION . . . 000500 FIND LAST PART. 000510 FIND FIRST SUPPLY WITHIN PART_INFO. 000520 FIND NEXT WITHIN PART_INFO. 000530 FIND FIRST VENDOR. . . . Statement 000500 sets the last occurrence of PART (TAPE) as current of record type PART. Statement 000510 sets the SUPPLY record occurrence (2-DAYS) as current of record type SUPPLY. Statement 000520 updates current of record type for SUPPLY to record occurrence (1-WEEK). Statement 000530 sets VENDOR record occurrence (MUSICO INC.
Example 5–3 Currency Indicators 000100 PROCEDURE DIVISION . . . 000490 100-FETCH-THE-PART. 000500 MOVE "TAPE" TO PART_DESC. 000510 FETCH FIRST PART USING PART_DESC. 000520 MOVE "A" TO SUP_RATING. 000550 200-FIND-SUPPLY. 000560 FIND NEXT SUPPLY WITHIN PART_INFO 000570 USING SUP_RATING. 000580 AT END 000590 GO TO 500-NO-MORE-SUPPLY. 000600 FETCH OWNER WITHIN VENDOR_SUPPLY. 000610 ************************ 000620 * VENDOR PRINT ROUTINE * 000630 ************************ 000640 GO TO 200-FIND-SUPPLY.
Figure 5–28 Currency Status by Executable DML Statement STATEMENT RUN UNIT REALM MARKET 510 MAKE BUY SET TYPE VENDOR_ SUPPLY PART_INFO RECORD PART VENDOR SUPPLY CASSETTE NULL NULL CASSETTE CASSETTE NULL CASSETTE NULL NULL *560 2−DAYS 2−DAYS NULL CASSETTE 2−DAYS 2−DAYS CASSETTE NULL 2−DAYS *600 MUSICO INC. MUSICO INC. NULL CASSETTE 2−DAYS MUSICO INC. CASSETTE MUSICO INC. 2−DAYS **560 5−DAYS NULL CASSETTE 5−DAYS 5−DAYS CASSETTE MUSICO INC.
Example 5–4 Using the RETAINING Clause 000100 PROCEDURE DIVISION. . . . 000400 100-VENDOR-SUPPLY-WALKTHRU. 000410 FETCH NEXT VENDOR WITHIN MARKET 000420 AT END GO TO 900-ALL-DONE. . . . ************************ * VENDOR PRINT ROUTINE * ************************ . . . 000500 300-GET-VENDORS-SUPPLY. 000510 FETCH NEXT SUPPLY WITHIN VENDOR_SUPPLY 000520 RETAINING REALM 000530 AT END 000540 GO TO 100-VENDOR-SUPPLY-WALKTHRU. . . . ************************ * SUPPLY PRINT ROUTINE * ************************ . . .
currency pointer, which points to MUSICO to fetch the next vendor, SOUNDOFF. Therefore, retaining the realm currency allows you to fetch the next logical vendor record. Figure 5–30 Physical Representation of a Realm with a RETAINING Clause 4−DAYS 2−WEEKS 2−DAYS MUSICO (start walkthrough) SOUND−OFF with retaining ZK−1507−GE 5.14.2 Using Keeplists A keeplist is a stack of database key values (see the description of KEEPLIST in LD (Keeplist Description)).
Figure 5–31 State of KEEPLIST-1 After Executing Line 000160 KEEPLIST−1 Database Key (DBKEY) ORDINAL POSITION vendor dbkey 1 ZK−6063−GE Figure 5–32 State of KEEPLIST-1 After Executing Lines 000190 and 000200 KEEPLIST−1 Database Key (DBKEY) ORDINAL POSITION vendor dbkey 1 supply dbkey 2 ZK−6064−GE You can use database key values as search arguments to locate database records.
This statement removes the fifth-positioned database key value from KEEPLIST2. Removing a keeplist entry changes the position of all the following entries. For example, after freeing entry 5, entry 6 becomes the fifth-positioned entry, entry 7 becomes the sixth-positioned entry, and so forth. The FREE statement changes the ordinal position of a database key value in the keeplist, not its contents. 5.14.
6 DML Programming—Tips and Techniques We’ve gathered some tips and techniques you can use to improve program performance and reduce development and debugging time. These include special use of modes, indicators, conditions and statements, as well as debugging techniques. 6.1 The Ready Modes Proper use of the READY usage modes can improve system performance. You inform the DBCS of your record-locking requirements when you issue the READY command.
• PROTECTED RETRIEVAL (the system default) • PROTECTED UPDATE • EXCLUSIVE RETRIEVAL • EXCLUSIVE UPDATE • BATCH RETRIEVAL • BATCH UPDATE Use the CONCURRENT usage modes for applications requiring separate run units to simultaneously access the database. They allow other run units to perform a READY statement on your realm, and possibly change or delete the database records in that realm. Use the PROTECTED usage modes only when unrestricted access might produce incorrect or incomplete results.
you specify CONCURRENT or PROTECTED modes, the DBCS initiates locking at the record level. Individual records are locked as they are retrieved by the run unit. The degree of locking depends on the specific DML command used. For example, if your run unit executes a FETCH or FIND statement, the DBCS sets a read-only record lock, allowing other run units to read, but not update, the records.
Figure 6–1 Using the COMMIT Statement Program Statement READY . . . COMMIT . . . READY . . . COMMIT . . .
Example 6–1 ROLLBACK Statement . . . READY-UPDATE. READY TEST_REALM CONCURRENT UPDATE. ************************** * FETCH CUSTOMER ROUTINE * ************************** . . . ******************************* * FETCH ORDERED ITEMS ROUTINE * ******************************* . . . CREDIT-LIMIT-CHECK. MULTIPLY ORDERED-QUANTITY BY UNIT-PRICE GIVING ORDER-AMOUNT. ADD ORDER-AMOUNT TO TOTAL-AMT. IF TOTAL-AMT IS GREATER THAN CUST-CREDIT-LIMIT ROLLBACK PERFORM CREDIT-LIMIT-EXCEEDED ELSE PERFORM PRINT-INVOICE-LINE. 6.
Example 6–2 Owner and Member Test Condition . . . 000130 MAIL-LINE ROUTINE. 000140 MOVE "PART D" TO PART_DESC. 000150 PERFORM FIND-PARTS. 000160 MOVE "PART L" TO PART_DESC. 000170 PERFORM FIND-PARTS. 000180 GO TO ALL-FINISHED. 000190 FIND-PARTS. 000200 FIND FIRST PART USING PART_DESC. 000210 IF PART-IS-MISSING 000220 PERFORM PART-MISSING. 000230 PERFORM PARTS-ANALYSIS. 000240 FIND OWNER WITHIN RESPONSIBLE_FOR. 000250 PERFORM WORKLOAD-ANALYSIS. 000250 DONE-ANALYSIS. 000260 EXIT. . . .
Figure 6–3 shows a set occurrence for SORT_SET where MEMBER-B’s key (KEY 3) was changed to KEY 8. Before altering the record’s key, the set currency pointed to MEMBER-B, and a FETCH NEXT MEMBER WITHIN SORT_SET fetched MEMBER-C. However, the modification to MEMBER-B’s key repositions the record within the set occurrence. Now, a FETCH NEXT MEMBER WITHIN SORT_SET fetches the MEMBER-D record.
Figure 6–4 After Modifying MEMBER_B and Using RETAINING SORT−OWNER MEMBER−A KEY 1 POSTION VACATED BY MEMBER−B (CURRENT OF SET) MEMBER−C MEMBER−D KEY 9 MEMBER−B KEY 8 KEY 6 ZK−1512−GE If MEMBER_B’s key was changed to KEY 4, the record’s position in the set occurrence would not change, and a FETCH NEXT WITHIN SORT_SET would fetch MEMBER_C. 6.6 CONNECT and DISCONNECT When the set membership class is MANUAL, use the CONNECT statement to link a member record to its set occurrence.
6.7 RECONNECT Use the RECONNECT statement to remove a member record from one set occurrence and connect it to another occurrence of the same set type, or to a different position within the same set. To transfer a member record: 1. Use the FETCH (or FIND) statement to select a record in the set occurrence. This can be either a member or an owner of the set occurrence you want to connect to. 2. Use the FETCH (or FIND) statement with the RETAINING clause to transfer the member record you want.
Example 6–3 RECONNECT Statement . . . GET-WORK-STATION. MOVE 2 TO WORK_STATION_ID. FIND FIRST WORK_STATION USING WORK_STATION_ID. MOVE "R" TO ASSEMBLY_ID. FIND FIRST ASSEMBLY USING ASSEMBLY_ID RETAINING ASSEMBLY_SET. ********************************************************* * The RETAINING clause retains work station 2 as * * current of ASSEMBLY_SET. Otherwise, the found member * * would be current of set and the RECONNECT would fail.
The occurrence diagrams in Figure 6–7 show the results of using the ERASE ALL statement. Figure 6–7 Results of an ERASE ALL PRIOR TO ERASE ALL AFTER ERASE ALL OWNER OWNER SET_A A1 A1 A4 SET_A A4 ERASE A2 B1 SET_B A3 A3 B3 SET_C C2 B2 C1 ZK−1515−GE The ERASE ALL statement is the only way to erase an owner of sets with MANDATORY members. 6.
Figure 6–8 Results of an ERASE Record-Name (with Both OPTIONAL and FIXED Retention Classes) PRIOR TO ERASE AFTER ERASE OWNER OWNER SET_A A1 A1 A4 SET_A A4 ERASE A2 B1 SET_B A3 A3 B3 SET_C C2 C1 C2 B2 C1 ZK−1516−GE Remember, records removed from a set but not deleted from the database can still be accessed. 6.10 Freeing Currency Indicators Use the FREE database-key-id statement to release the currency indicators for realms, records, sets, or the run unit.
Example 6–4 FREE CURRENT Statement . . . MAIN-ROUTINE. READY TEST_REALM CONCURRENT RETRIEVAL. PERFORM FIRST-REPORT-HEADINGS. PERFORM PRINT-FIRST-REPORT THRU PFR-EXIT UNTIL AT-END = "Y". MOVE "N" TO AT-END. PERFORM SECOND-REPORT-HEADINGS. PERFORM PRINT-SECOND-REPORT THRU PSR-EXIT UNTIL AT-END = "Y". MOVE "N" TO AT-END. PERFORM THIRD-REPORT-HEADINGS. PERFORM PRINT-THIRD-REPORT THRU PTR-EXIT UNTIL AT-END = "Y". MOVE "N" TO AT-END. . . . STOP RUN. PRINT-FIRST-REPORT.
6.10.2 Releasing Record Locks Regardless of the READY mode used, you always have a record lock on the current of run unit. Even the READY CONCURRENT RETRIEVAL mode locks the current record and puts it in a read-only condition. Furthermore, if you are traversing the database, the current record for each record type you touch with a DML statement is locked and placed in a read-only condition. Record locking prevents other users from updating any records locked by your run unit.
The following example locates all PART records with a PART_STATUS of J and puts their dbkey values in keeplist TWO. FIND ALL TWO PART USING PART_STATUS PART_STATUS X(l) = J 6.13 FIND NEXT and FETCH NEXT Loops If you have a FIND NEXT or FETCH NEXT loop in your program, the first execution of the loop is the same as executing a FIND FIRST or FETCH FIRST. Unless you properly initialize them, currency indicators can affect selection of the specified record.
Example 6–5 (Cont.) FETCH NEXT Loop 000170 FREE CURRENT. 000180 ANALYZE-INVENTORY. 000190 FETCH NEXT INV_ITEMS 000200 AT END GO TO END-OF-PROGRAM. 000210 GO TO ANALYZE-INVENTORY. . . . You can also use FETCH NEXT and FIND NEXT loops to walk through a set type. Assume you have to walk through the WAREHOUSE_SET and reduce the reorder point quantity by 10 percent for all items with a cost greater than $500. Furthermore, you also want to check the supplier’s credit terms for each of these items.
6.14 Qualifying FIND and FETCH You can locate records by using the contents of data items as search arguments. You can use more than one qualifier as a search argument. For example, assume you want to print a report of all employees in department 5 with a pay rate of $7.50 per hour. You could use the department number as a search argument and use a conditional test to find all employees with a pay rate of $7.50. Or you could use both the department number and pay rate as search arguments, as follows: . . .
7 Debugging and Testing HP COBOL DML Programs The Database Query utility (DBQ) commands and generic DML statements are the tools you use to debug and test your HP COBOL program’s DML statements. For example, you can use DBQ commands to display currency indicators, test program loops, or check your program’s execution efficiency. It is important to eliminate any logic errors prior to running an HP COBOL DML program against a live database, because poorly written or incorrect logic can corrupt a database.
• DB statement—Use the DBQ utility BIND command to identify the subschema you will use for testing and debugging. You cannot access a subschema until you bind it. If your program has this DB statement: DB PARTSS3 WITHIN PARTS FOR NEW. the comparable BIND statement is as follows: dbq>BIND PARTSS3 FOR NEW • ANY clause—The DBQ utility does not allow the ANY clause in a Record Selection Expression. Instead, use the FIRST clause.
Example 7–1 Sample HP COBOL DML Program Statements DATA DIVISION. DB PARTSS3 WITHIN PARTS FOR NEW. . . . PROCEDURE DIVISION. 000-BEGIN. READY PROTECTED UPDATE. . . . MOVE "AZ177311" TO PART_ID. FETCH FIRST PART USING PART_ID. MOVE "N" TO END-OF-COLLECTION. PERFORM A100-LOOP THROUGH A100-LOOP-EXIT UNTIL END-OF-COLLECTION = "Y". . . . STOP RUN. A100-LOOP. FETCH NEXT WITHIN PART_SUPPLY AT END MOVE "Y" TO END-OF-COLLECTION GO TO A100-LOOP-EXIT.
Figure 7–1 Split Screen After FETCH FIRST PART USING PART_ID Legend: CURRENT POSITION maintained null PART PART_SUPPLY supply %DBM − I − CURDISPLA, %DBM − I − CURDISPLA, %DBM − I − CURDISPLA, %DBM − I − CURDISPLA, PART_ID = AZ177311 PART_DESC = GASKET PART_STATUS = G PART_SUPPORT = RE Currency Currency Currency Currency for for for for run unit is 1:2:7 PART_SUPPLY set type is 1:2:7 PART record type is 1:2:7 MARKETS realm is 1:2:7 ZK−6067−GE The next DML statement in Figure 7–2 is FETCH NEXT WITHIN
Figure 7–2 Split Screen After FETCH NEXT WITHIN PART_SUPPLY Legend: CURRENT POSITION maintained null PART vendor PART_SUPPLY VENDOR_SUPPLY SUPPLY %DBM − I − CURDISPLA, Currency %DBM − I − CURDISPLA, Currency %DBM − I − CURDISPLA, Currency %DBM − I − CURDISPLA, Currency %DBM − I − CURDISPLA, Currency SUP_RATING = 0 SUP_TYPE = OEM SUP_LAG_TIME = 6−10 DAYS for for for for for run unit is 3:2:3 PART_SUPPLY set type is 3:2:3 VENDOR_SUPPLY set type is 3:2:3 SUPPLY record type is 3:2:3 MARKETS realm is 3:2
Figure 7–3 Split Screen After MODIFY SUP_RATING Legend: CURRENT POSITION maintained null PART vendor PART_SUPPLY VENDOR_SUPPLY SUPPLY ZK−6069−GE The next statement to test is the FETCH for SUPPLY record’s owner in the VENDOR_SUPPLY set.
that a MODIFY to the PART record will not work even before you attempt the MODIFY statement. To correct the logic error, PART must be the current record type prior to execution of the MODIFY PART_STATUS statement. One way to correct the logic error is to execute a FETCH CURRENT PART statement before the MODIFY PART_ STATUS statement. Example 7–2 shows a corrected version of the sample COBOL DML program statements in Example 7–1. Example 7–2 Sample DML Program Statements DATA DIVISION.
RETAINING clause, a FETCH NEXT WITHIN PART_SUPPLY would use PART’s currency and FETCH the first SUPPLY record belonging to PART.
Figure 7–6 Split Screen After FETCH NEXT WITHIN PART_SUPPLY Legend: CURRENT POSITION maintained null PART VENDOR PART_SUPPLY VENDOR_SUPPLY SUPPLY %DBM − I − CURDISPLA, Currency %DBM − I − CURDISPLA, Currency %DBM − I − CURDISPLA, Currency %DBM − I − CURDISPLA, Currency %DBM − I − CURDISPLA, Currency SUP_RATING = 0 SUP_TYPE = WSUP SUP_LAG_TIME = 1−2 WEEKS for for for for for run unit is 3:2:2 PART_SUPPLY set type is 3:2:2 VENDOR_SUPPLY set type is 3:2:2 SUPPLY record type is 3:2:2 MARKETS realm is 3:
Figure 7–7 Split Screen After FETCH 2 WITHIN PART_SUPPLY Legend: CURRENT POSITION maintained null PART VENDOR PART_SUPPLY VENDOR_SUPPLY SUPPLY %DBM − I − CURDISPLA, Currency %DBM − I − CURDISPLA, Currency %DBM − I − CURDISPLA, Currency %DBM − I − CURDISPLA, Currency %DBM − I − CURDISPLA, Currency SUP_RATING = 0 SUP_TYPE = WSUP SUP_LAG_TIME = 1−2 WEEKS for for for for for run unit is 3:2:2 PART_SUPPLY set type is 3:2:2 VENDOR_SUPPLY set type is 3:2:2 SUPPLY record type is 3:2:2 MARKETS realm is 3:2:2
Example 7–3 PARTSS1-PROGRAM Compiler Listing (Alpha, I64) PARTSS1-PROGRAM 0 1 2 3 4 5 6 7 8 9 Source Listing Source Listing 18-JUN-2004 08:20:37 HP COBOL V2.8 Page 1 18-JUN-2004 08:17:19 DEVICE:[COBOL.EXAMPLES]PARTSS1.COB;1 IDENTIFICATION DIVISION. PROGRAM-ID. PARTSS1-PROGRAM. DATA DIVISION. SUB-SCHEMA SECTION. DB PARTSS5 WITHIN PARTS FOR "DBM$IVP_OUTPUT:DBMPARTS". PROCEDURE DIVISION. END PROGRAM PARTSS1-PROGRAM. PARTSS1-PROGRAM 0 Source Listing 18-JUN-2004 08:20:37 HP COBOL V2.
Example 7–3 (Cont.
PARTSS3 Program Map Listing (Alpha, I64) PARTSS3-PROGRAM in Example 7–4 includes the Oracle CODASYL DBMS data-names of the PARTSS3 subschema. Example 7–4 PARTSS3-PROGRAM Compiler Listing (Alpha, I64) PARTSS3-PROGRAM 0 1 2 3 4 5 6 7 8 9 Source Listing Source Listing 18-JUN-2004 08:33:40 HP COBOL V2.8 Page 1 18-JUN-2004 08:30:39 DEVICE:[COBOL.EXAMPLES]PARTSSE.COB;1 IDENTIFICATION DIVISION. PROGRAM-ID. PARTSS3-PROGRAM. DATA DIVISION. SUB-SCHEMA SECTION. DB PARTSS3 WITHIN PARTS FOR "DBM$IVP_OUTPUT:DBMPARTS".
Example 7–4 (Cont.) PARTSS3-PROGRAM Compiler Listing (Alpha, I64) Line ----2 Name Location ---------- ------------PARTSS3-PROGRAM ** Type ------------------------------------------------------------------------Program PARTSS3_PROGRAM\PARTSS3_PROGRAM Source Listing 0 Compilation Summary 18-JUN-2004 08:33:40 HP COBOL V2.8 Page 5 18-JUN-2004 08:30:39 DEVICE:[COBOL.EXAMPLES]PARTSSE.
Example 7–5 PARTSS1-PROGRAM Compiler Listing (VAX) PARTSS1-PROGRAM Source Listing 31-May-2004 14:08:50 Compaq COBOL V5.7-63 Page 1 31-May-2004 14:03:05 [SYSTEST.DBM]PARTSS1-PROGRAM.COB;3 (1) 1 IDENTIFICATION DIVISION. 2 PROGRAM-ID. PARTSS1-PROGRAM. 3 4 DATA DIVISION. 5 SUB-SCHEMA SECTION. 6 DB PARTSS5 WITHIN PARTS. 7 8 PROCEDURE DIVISION. 9 END PROGRAM PARTSS1-PROGRAM. PARTSS1-PROGRAM 31-May-2004 14:08:50 Compaq COBOL V5.7-63 Page 2 Data Names in Alphabetic Order 31-May-2004 14:03:05 [SYSTEST.
Example 7–5 (Cont.) PARTSS1-PROGRAM Compiler Listing (VAX) PARTSS1-PROGRAM 31-May-2004 14:08:50 Compaq COBOL V5.7-63 Page 3 Procedure Names in Alphabetic Order 31-May-2004 14:03:05 [SYSTEST.DBM]PARTSS1-PROGRAM.COB;3 (1) Line Name 2 PARTSS1-PROGRAM PARTSS1-PROGRAM References Location Type 0 00000000 Program 31-May-2004 14:08:50 Compaq COBOL V5.7-63 Page 4 31-May-2004 14:03:05 [SYSTEST.DBM]PARTSS1-PROGRAM.COB;3 (1) DBM$_NOT_BOUND PARTSS1-PROGRAM 31-May-2004 14:08:50 Compaq COBOL V5.
Example 7–5 (Cont.) PARTSS1-PROGRAM Compiler Listing (VAX) PARTSS1-PROGRAM Sub-schema Map 31-May-2004 14:08:50 Compaq COBOL V5.7-63 Page 6 31-May-2004 14:03:05 [SYSTEST.DBM]PARTSS1-PROGRAM.COB;3 (1) * PART_INFO * PART_USED_ON * Member of sets: ALL_PARTS * ALL_PARTS_ACTIVE * CATEGORY_PART * RESPONSIBLE_FOR * 01 PART. 02 PART_ID PIC X(8). 02 PART_DESC PIC X(50). 02 PART_STATUS PIC X. 02 PART_PRICE PIC S9(6)V9(3) COMP-3. 02 PART_COST PIC S9(6)V9(3) COMP-3. 02 PART_SUPPORT PIC X(2).
Example 7–5 (Cont.
Example 7–5 (Cont.) PARTSS1-PROGRAM Compiler Listing (VAX) PARTSS1-PROGRAM Compilation Summary PROGRAM SECTIONS Name 0 3 4 5 7 31-May-2004 14:08:50 Compaq COBOL V5.7-63 Page 9 31-May-2004 14:03:05 [SYSTEST.DBM]PARTSS1-PROGRAM.
Example 7–6 (Cont.) PARTSS3-PROGRAM Compiler Listing (VAX) PARTSS3-PROGRAM Data Names in Alphabetic Order Line Level 6 6 01 01 31-May-2004 12:31:18 Compaq COBOL V5.7-63 Page 2 31-May-2004 12:25:37 [SYSTEST.DBM]PARTSS3-PROGRAM.
Example 7–6 (Cont.) PARTSS3-PROGRAM Compiler Listing (VAX) * Within areas: MARKETS * Owner of sets: VENDOR_SUPPLY * 01 VENDOR. 02 VEND_ID PIC X(8). 02 VEND_NAME PIC X(40). 02 VEND_CONTACT PIC X(30). 02 VEND_ADDRESS PIC X(15) OCCURS 3 TIMES. 02 VEND_PHONE PIC 9(10).
8 Database Programming Examples The next few pages show programming examples of how to do the following: • Populate a database • Back up a database • Access and display database information • Create new record relationships This chapter also provides an example of how to create a bill of materials and sample runs of some of the programming examples. 8.1 Populating a Database The DBMPARTLD program in Example 8–1 loads a series of sequential data files into the PARTS database.
Example 8–1 (Cont.) Populating a Database INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT MAKE-FILE ASSIGN TO "DBM$PARTS:DBMMAKE.DAT". SELECT BUY-FILE ASSIGN TO "DBM$PARTS:DBMBUY.DAT". SELECT VENDOR-FILE ASSIGN TO "DBM$PARTS:DBMVENDOR.DAT". SELECT EMPLOYEE-FILE ASSIGN TO "DBM$PARTS:DBMEMPLOY.DAT". SELECT COMPONENT-FILE ASSIGN TO "DBM$PARTS:DBMCOMPON.DAT". SELECT SUPPLY-FILE ASSIGN TO "DBM$PARTS:DBMSUPPLY.DAT". SELECT DIVISION-FILE ASSIGN TO "DBM$PARTS:DBMSUPER.DAT".
Example 8–1 (Cont.) Populating a Database FD VENDOR-FILE LABEL RECORDS ARE STANDARD. 01 VENDOR-RECORD. 02 VEND_ID PIC X(8). 02 VEND_NAME PIC X(40). 02 VEND_CONTACT PIC X(30). 02 VEND_ADD OCCURS 3 TIMES PIC X(15). 02 VEND_PHONE PIC 9(10). FD SUPPLY-FILE RECORD VARYING FROM 37 TO 64 CHARACTERS. 01 SUPPLY-RECORD. 02 CONTROL-FIELD PIC X. 02 PART-ID PIC X(8). 02 VEND-NAME PIC X(40). 02 SUP_RATING PIC X. 02 SUP_TYPE PIC X(4). 02 SUP_LAG_TIME PIC X(10). 01 QUOTE-RECORD. 02 CONTROL-FIELD PIC X.
Example 8–1 (Cont.) Populating a Database WORKING-STORAGE SECTION. 77 77 77 77 77 77 77 77 77 77 77 ITEM-USED STAT DB-TEMP CLASS-COUNT PART-COUNT COMPONENT-COUNT VENDOR-COUNT SUPPLY-COUNT QUOTE-COUNT EMPLOYEE-COUNT DIVISION-COUNT PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC PIC X(70). 9(9) USAGE COMP. 9(9) USAGE IS COMP. 999 VALUE IS 0. 999 VALUE IS 0. 999 VALUE IS 0. 999 VALUE IS 0. 999 VALUE IS 0. 999 VALUE IS 0. 999 VALUE IS 0. 999 VALUE IS 0. PROCEDURE DIVISION. DECLARATIVES.
Example 8–1 (Cont.) Populating a Database OPEN INPUT COMPONENT-FILE. PERFORM COMPONENT-LOAD THRU COMPONENT-LOAD-END. CLOSE COMPONENT-FILE. * DISPLAY " ". * DISPLAY COMPONENT-COUNT, " COMPONENT records loaded". * * OPEN INPUT EMPLOYEE-FILE. PERFORM EMPLOYEE-LOAD THRU EMPLOYEE-LOAD-END. CLOSE EMPLOYEE-FILE. DISPLAY " ". DISPLAY EMPLOYEE-COUNT, " EMPLOYEE records loaded". * * * OPEN INPUT SUPPLY-FILE. PERFORM SUPPLY-LOAD THRU SUPPLY-LOAD-END. CLOSE SUPPLY-FILE. DISPLAY " ".
Example 8–1 (Cont.) Populating a Database VENDOR-LOAD. READ VENDOR-FILE AT END GO TO VENDOR-LOAD-END. MOVE VEND_ID OF VENDOR-RECORD TO VEND_ID OF VENDOR. MOVE VEND_NAME OF VENDOR-RECORD TO VEND_NAME OF VENDOR. MOVE VEND_CONTACT OF VENDOR-RECORD TO VEND_CONTACT OF VENDOR. MOVE VEND_ADD (1) TO VEND_ADDRESS (1). MOVE VEND_ADD (2) TO VEND_ADDRESS (2). MOVE VEND_ADD (3) TO VEND_ADDRESS (3). MOVE VEND_PHONE OF VENDOR-RECORD TO VEND_PHONE OF VENDOR. STORE VENDOR. ADD 1 TO VENDOR-COUNT. GO TO VENDOR-LOAD.
Example 8–1 (Cont.) Populating a Database SUPPLY-LOAD. READ SUPPLY-FILE AT END GO TO SUPPLY-LOAD-END. SUPPLY-LOAD-LOOP.
Example 8–1 (Cont.) Populating a Database DIVISION-LOAD-LOOP.
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.
Example 8–2 (Cont.) Backing Up a Database INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT MAKE-FILE ASSIGN TO "DBM$PARTS:DBMMAKE.DAT". SELECT BUY-FILE ASSIGN TO "DBM$PARTS:DBMBUY.DAT". SELECT VENDOR-FILE ASSIGN TO "DBM$PARTS:DBMVENDOR.DAT". SELECT EMPLOYEE-FILE ASSIGN TO "DBM$PARTS:DBMEMPLOY.DAT". SELECT COMPONENT-FILE ASSIGN TO "DBM$PARTS:DBMCOMPON.DAT". SELECT SUPPLY-FILE ASSIGN TO "DBM$PARTS:DBMSUPPLY.DAT". SELECT DIVISION-FILE ASSIGN TO "DBM$PARTS:DBMSUPER.DAT".
Example 8–2 (Cont.) Backing Up a Database FD COMPONENT-FILE LABEL RECORDS ARE STANDARD. 01 COMPONENT-RECORD. 02 COMP_SUB_PART PIC X(8). 02 COMP_OWNER_PART PIC X(8). 02 COMP_MEASURE PIC X. 02 COMP_QUANTITY PIC 9(5). FD 01 FD 01 01 FD 01 FD 01 01 FD 01 VENDOR-FILE LABEL RECORDS ARE STANDARD. VENDOR-RECORD. 02 VEND_ID 02 VEND_NAME 02 VEND_CONTACT 02 VEND_ADDRESS OCCURS 3 TIMES 02 VEND_PHONE PIC PIC PIC PIC PIC X(8). X(40). X(30). X(15). 9(10). SUPPLY-FILE RECORD VARYING FROM 37 TO 64 CHARACTERS.
Example 8–2 (Cont.) Backing Up a Database WORKING-STORAGE SECTION. 77 77 77 77 77 77 77 CLASS-COUNT PART-COUNT COMPONENT-COUNT VENDOR-COUNT SUPPLY-COUNT QUOTE-COUNT EMPLOYEE-COUNT PIC PIC PIC PIC PIC PIC PIC 999 999 999 999 999 999 999 VALUE VALUE VALUE VALUE VALUE VALUE VALUE IS IS IS IS IS IS IS 0. 0. 0. 0. 0. 0. 0. PROCEDURE DIVISION. DECLARATIVES. 100-DATABASE-EXCEPTIONS SECTION. USE FOR DB-EXCEPTION ON OTHER. 100-PROCEDURE. DISPLAY "DATABASE EXCEPTION CONDITION". PERFORM 150-DISPLAY-MESSAGE.
Example 8–2 (Cont.) Backing Up a Database OPEN OUTPUT EMPLOYEE-FILE, RESP-FOR-FILE, DIVISION-FILE. PERFORM EMPLOYEE-UNLOAD THRU EMPLOYEE-UNLOAD-END. CLOSE EMPLOYEE-FILE, RESP-FOR-FILE, DIVISION-FILE. DISPLAY " ". DISPLAY EMPLOYEE-COUNT, " EMPLOYEE records unloaded". COMMIT. STOP RUN. MAKE-UNLOAD. FETCH NEXT CATEGORY WITHIN MAKE AT END GO TO MAKE-UNLOAD-END. MOVE "C" TO CONTROL-FIELD OF MAKE-CLASS-RECORD. MOVE CORR CATEGORY TO MAKE-CLASS-RECORD. ADD 1 TO CLASS-COUNT. WRITE MAKE-CLASS-RECORD. MAKE-PART-LOOP.
Example 8–2 (Cont.) Backing Up a Database SUPPLY-QUOTE-LOOP. FETCH NEXT WITHIN PART_INFO RETAINING REALM AT END GO TO COMPONENT-SUPPLY-UNLOAD-END.
Example 8–2 (Cont.) Backing Up a Database CONSISTS-UNLOAD. FETCH NEXT WITHIN CONSISTS_OF RETAINING MANAGES ALL_EMPLOYEES AT END GO TO DIVISION-UNLOAD. MOVE "C" TO CONTROL-FIELD OF CONSISTS-RECORD. MOVE EMP_ID OF EMPLOYEE TO EMP_ID OF CONSISTS-RECORD. WRITE CONSISTS-RECORD. GO TO CONSISTS-UNLOAD. RESP-UNLOAD. FETCH CURRENT WITHIN ALL_EMPLOYEES. RESP-UNLOAD-LOOP. FETCH NEXT WITHIN RESPONSIBLE_FOR AT END GO TO EMPLOYEE-UNLOAD. MOVE PART_ID OF PART TO PART_ID OF RESP-FOR-RECORD.
Example 8–3 (Cont.) Accessing and Displaying Database Information SOLICIT-INPUT. MOVE ZERO TO END-OF-COLLECTION. DISPLAY " ". DISPLAY "Enter PART_ID> " WITH NO ADVANCING. MOVE SPACES TO INPUT-REC. ACCEPT PART_ID AT END GO TO PARTBOM-DONE. FETCH FIRST PART WITHIN ALL_PARTS USING PART_ID AT END DISPLAY "*** Part number ", PART_ID, " not found. ***" GO TO SOLICIT-INPUT. DISPLAY " ". DISPLAY " ". DISPLAY "+-----------------------------------+". DISPLAY "| Parts Bill of Materials Explosion |".
8.4 PARTBOM Sample Run Example 8–4 displays a sample run of the PARTBOM program in Example 8–3.
Example 8–5 Creating Relationships Between Records of the Same Type IDENTIFICATION DIVISION. PROGRAM-ID. STOOL. DATA DIVISION. SUB-SCHEMA SECTION. DB PARTSS1 WITHIN PARTS FOR "NEW.ROO". LD KEEP-COMPONENT. WORKING-STORAGE SECTION. 01 DB-ERROR-CHECK PIC 9. 88 DB-ERROR VALUE 1. 88 DB-OK VALUE 0. 01 DB-COND PIC 9(9). 01 DB-ID PIC 9(4). PROCEDURE DIVISION. A000-BEGIN. READY USAGE-MODE IS CONCURRENT UPDATE. MOVE 0 TO DB-ERROR-CHECK. PERFORM B000-STORE-PARTS THROUGH B300-BUILD-AND-STORE-STOOL-LEG.
Example 8–5 (Cont.) Creating Relationships Between Records of the Same Type B300-BUILD-AND-STORE-STOOL-LEG. MOVE "SAMP3" TO PART_ID. MOVE "STOOL LEGS" TO PART_DESC. MOVE "G" TO PART_STATUS. MOVE 2 TO PART_PRICE. MOVE 1 TO PART_COST. MOVE SPACES TO PART_SUPPORT. IF DB-OK STORE PART ON ERROR DISPLAY "B300 Error in storing STOOL LEGS" PERFORM 900-DISPLAY-DB-CONDITION MOVE 1 TO DB-ERROR-CHECK. C000-STORE-COMPONENTS. MOVE "STOOL" TO PART_DESC. C100-FIND-STOOL.
Example 8–5 (Cont.) Creating Relationships Between Records of the Same Type C500-CONNECT-COMPONENT-4. MOVE "SAMP3" TO COMP_SUB_PART. MOVE "SAMP1" TO COMP_OWNER_PART. MOVE "U" TO COMP_MEASURE. MOVE 4 TO COMP_QUANTITY. IF DB-OK STORE COMPONENT ON ERROR DISPLAY "C000 Error in storing second component" PERFORM 900-DISPLAY-DB-CONDITION MOVE 1 TO DB-ERROR-CHECK. 800-VERIFY-ROUTINE. CALL "PARTBOM". 900-DISPLAY-DB-CONDITION. MOVE DB-CONDITION TO DB-COND. MOVE DB-CURRENT-RECORD-ID TO DB-ID.
Example 8–5 (Cont.) Creating Relationships Between Records of the Same Type SOLICIT-INPUT. MOVE ZERO TO END-OF-COLLECTION. DISPLAY " ". DISPLAY "Enter PART_ID> " WITH NO ADVANCING. MOVE SPACES TO INPUT-REC. READ INPUT-FILE INTO PART_ID AT END GO TO PARTBOM-DONE. FETCH FIRST PART WITHIN ALL_PARTS USING PART_ID AT END DISPLAY "*** Part number ", PART_ID, " not found. ***" GO TO SOLICIT-INPUT. DISPLAY " ". DISPLAY " ". DISPLAY DISPLAY "+-----------------------------------+".
8.6 STOOL Program Parts Breakdown Report—Sample Run This is the report output by the STOOL program in Example 8–5. Enter PARTID> (SAMP1 RET +-----------------------------------+ | Parts Bill of Materials Explosion | | (COBOL Version) | | Part-id: SAMP1 | +-----------------------------------+ SAMP1 SAMP3 SAMP2 - STOOL - STOOL LEGS - STOOL SEAT Enter PARTID> End of Job ctrl/z 8.
Example 8–6 (Cont.) Creating New Record Relationships PROCEDURE DIVISION. A000-BEGIN. READY USAGE-MODE IS UPDATE. PERFORM A100-EMPLOYEE-LOAD. PERFORM A200-CONNECTING-TO-CONSISTS-OF. DISPLAY "Employees and groups are loaded". DISPLAY "Personnel Report before update ..." CALL "PERSONNEL-REPORT". DISPLAY "Press your carriage return key to continue". ACCEPT ANSWER. CALL "PROMOTION-UPDATE". DISPLAY "Promotions completed". DISPLAY "Press your carriage return key to continue". ACCEPT ANSWER.
Example 8–6 (Cont.) Creating New Record Relationships MOVE 07000 TO MOVE "NEILS" TO MOVE "ALBERT" TO MOVE 7777777 TO MOVE "N.H." TO STORE EMPLOYEE. EMP_ID. EMP_LAST_NAME. EMP_FIRST_NAME. EMP_PHONE. EMP_LOC. MOVE 05000 TO MOVE "KLEIN" TO MOVE "DON" TO MOVE 8888888 TO MOVE "N.H." TO STORE EMPLOYEE. EMP_ID. EMP_LAST_NAME. EMP_FIRST_NAME. EMP_PHONE. EMP_LOC. MOVE 02000 TO MOVE "DEANE" TO MOVE "FRANK" TO MOVE 9999999 TO MOVE "N.H." TO STORE EMPLOYEE. EMP_ID. EMP_LAST_NAME. EMP_FIRST_NAME. EMP_PHONE.
Example 8–6 (Cont.) Creating New Record Relationships MOVE 04000 TO EMP_ID. FIND FIRST EMPLOYEE WITHIN ALL_EMPLOYEES USING EMP_ID. CONNECT EMPLOYEE TO CONSISTS_OF. MOVE 07000 TO EMP_ID. FIND FIRST EMPLOYEE WITHIN ALL_EMPLOYEES USING EMP_ID. CONNECT EMPLOYEE TO CONSISTS_OF. MOVE 06600 TO EMP_ID. FIND FIRST EMPLOYEE WITHIN ALL_EMPLOYEES USING EMP_ID. MOVE "B2" TO GROUP_NAME. STORE WK_GROUP. MOVE 01400 TO EMP_ID. FIND FIRST EMPLOYEE WITHIN ALL_EMPLOYEES USING EMP_ID. CONNECT EMPLOYEE TO CONSISTS_OF.
Example 8–6 (Cont.) Creating New Record Relationships * * The next two sentences create and store a WK_GROUP record. * Because KLEIN is current of EMPLOYEE, a STORE WK_GROUP * automatically connects WK_GROUP as a member of the MANAGES * set owned by KLEIN, and makes "B3" current of the MANAGES * and CONSISTS_OF sets. * MOVE "B3" TO WK_GROUP. STORE WK_GROUP. * * The next two statements fetch NEILS and retain WK_GROUP * "B3" as current of CONSISTS_OF. * MOVE 7000 TO EMP_ID.
Example 8–6 (Cont.) Creating New Record Relationships REPORT SECTION. RD PERSONNEL-LISTING PAGE LIMIT IS 66 HEADING 1 FIRST DETAIL 3 LAST DETAIL 60 CONTROLS ARE MANAGES-GROUP SUPERVISES-GROUP. 01 TYPE IS PAGE HEADING. 02 LINE 1 COLUMN 22 PIC X(16) VALUE "EMPLOYEE LISTING". 01 MANAGER-CONTROL TYPE IS CONTROL HEADING MANAGES-GROUP. 02 LINE IS PLUS 1. 03 COLUMN 16 PIC X(17) VALUE "MANAGER OF GROUP ". 03 COLUMN 33 PIC XX SOURCE MANAGES-GROUP. 03 COLUMN 35 PIC XXXX VALUE "IS: ".
Example 8–6 (Cont.) Creating New Record Relationships A100-GET-THE-BOSS. MOVE 10500 TO EMP_ID. FETCH FIRST EMPLOYEE USING EMP_ID. MOVE EMP_LAST_NAME TO MANAGER-NAME. FETCH FIRST WK_GROUP WITHIN MANAGES. MOVE GROUP_NAME TO MANAGES-GROUP. A200-GET-SUPERVISORS. FETCH NEXT EMPLOYEE WITHIN CONSISTS_OF AT END GO TO A700-DONE-THE-BOSS. MOVE EMP_LAST_NAME TO SUPERVISOR-NAME. KEEP CURRENT USING KEEPSUPER. FETCH NEXT WK_GROUP WITHIN MANAGES. MOVE GROUP_NAME TO SUPERVISES-GROUP.
Example 8–7 (Cont.) Sample Run of PERSONNEL-UPDATE Before Promotion GROUP B1 SUPERVISOR IS: NOYCE GROUP B1 EMPLOYEES EMPLOYEE NUMBER 04000 07000 01000 EMPLOYEE NAME BURLEW NEILS RAVAN 8.7.2 PERSONNEL-UPDATE Sample Run—Listing After Promotion This sample report (Example 8–8, created by PERSONNEL-UPDATE in Section 8.7, corresponds to the data in Figure 5–26.
A COBOL Database Programming Reserved Words The italicized words in this list are relevant to (both) database programs and other programs.
END-READY END-RECONNECT END-ROLLBACK END-STORE ERROR EXCLUSIVE FETCH FIND FIRST FREE GET KEEP LAST LD LIMIT LIMITS MATCH MATCHES MEMBER MEMBERSHIP MODIFY NEXT NULL OFFSET OTHER OTHERS OWNER PRIOR PROTECTED READY REALM REALMS RECONNECT RECORD RELATIVE RETAINING ROLLBACK SET SETS STORE SUB-SCHEMA TENANT A–2 COBOL Database Programming Reserved Words
UPDATE UPDATERS USING WAIT WHERE WITHIN COBOL Database Programming Reserved Words A–3
Glossary of Oracle DBMS-Related Terms access mode In a database environment, that part of the COBOL data manipulation language READY statement’s usage mode that describes what capabilities your run unit will have with regard to records in the realm you have readied. The access mode can be RETRIEVAL (read only) or UPDATE (read and write). See also usage mode and allow mode.
CDD/Repository See Oracle CDD/Repository. CODASYL An acronym for the COnference on DAta SYstems Languages, the committee that produced the document titled CODASYL COBOL Journal of Development. This document serves as the basis for the standardization of the Oracle CODASYL DBMS data manipulation language (DML). CONCURRENT usage mode The state of a realm in which it may be accessed by concurrent run units.
database exception condition The state that exists for a run unit when the DBCS detects a situation for that run unit that requires special handling. database item An elementary data item defined in a subschema. It corresponds uniquely to a data item in the subschema’s host schema. database key (dbkey) A numeric value that uniquely identifies a record in the database. The Database Control System assigns the value when a record is stored in the database.
DB-CURRENT-RECORD-ID A database special register containing the subschema user ID number (UID) of the record type of the current record of the run unit. It contains zero if there is no current record of the run unit. DB-CURRENT-RECORD-NAME A database special register containing the name of the record type of the current record of the run unit. It contains spaces if there is no current record of the run unit. DBA See database administrator. DBCS See Database Control System. dbkey See database key.
empty set A database set occurrence containing no member records. EXCLUSIVE usage mode The state of a realm in which it cannot be accessed by a concurrent run unit. FIXED member A record, upon becoming a member of a set occurrence of a FIXED set type, that must remain a member of that set until it is erased from the database. Fixed set membership is declared in the schema DDL. Compare with MANDATORY member.
member condition The condition, for which a truth value can be determined, that a database record is a member of one or more sets. member record A database record, other than the owner record, included in the set. There may be one or more member record types in a set. There may be zero or more member records in a set. nonsingular set A database set not owned by the SYSTEM. See also SYSTEM-owned set and owner record. null A data attribute associated with currency indicators and database key values.
realm currency indicator A currency indicator (in other words, database key value) associated with a particular realm. A realm currency indicator identifies a particular database record, position in the realm, or both. record key A key whose contents identify a record in an indexed file or within a record type in a database. Within an indexed file, record key is either the prime record key or an alternate record key. Within a database, a record key may or may not have ordering significance.
set A defined relationship among records in a database. A set contains an owner record and zero or more member records. See also set occurrence , set type, and empty set. set member A record stored in the database as a nonowner participant in a specific set. set-name A user-defined word that identifies a set type. set occurrence An instance of a database set type. A set occurrence is the actual data in the set, not its definition, which is the set type.
storage schema DDL The language used to define the physical organization of the database. SUB-SCHEMA SECTION The section of the Data Division that defines the subschema and keeplists to be used by the COBOL program. subschema A user view of a database. The subschema can include everything in the original schema DDL or any part thereof. The subschema is written using the subschema data definition language (subschema DDL). subschema DDL The language used to define the user view of a database.
PROTECTED RETRIEVAL PROTECTED UPDATE BATCH RETRIEVAL BATCH UPDATE PROTECTED and RETRIEVAL are the default. See also access mode and allow mode. user work area (UWA) A portion of memory assigned to the program’s run unit at run time. The run unit delivers data for the DBCS to this area, and it is here the DBCS places data requested from the database for retrieval by the run unit.
Index A Access database key identifier, 1–4 record search, 1–4 set owner, 1–4 Access mode BATCH, 6–1 CONCURRENT, 6–1 EXCLUSIVE, 6–1 lock, 6–3 PROTECTED, 6–1 UPDATE, 6–1 ANY clause, 7–2 AT END phrase, 4–17, 4–32, 4–37, 7–1 Automatic ROLLBACK, 6–4 AUTOMATIC set membership class, 6–8 B BATCH access mode, 6–1 BATCH RETRIEVAL allow mode, 6–2 usage mode, 6–2 BATCH UPDATE allow mode, 6–2 usage mode, 6–2 BIND command, 7–2 C Called programs Linkage Section of, 3–3 Procedure Division header of, 3–3 Cascade delete,
Database (cont’d) conditional expression, 1–4 CONNECT statement, 6–8 copying database records, 1–5 creating, 5–3 creating an HP COBOL DML program, 1–4 creating new record relationships, 8–22 creating records, 1–4 currency indicators, 5–25, 5–28 example, 5–28 freeing, 6–12 example, 6–13 null, 5–26 realm, 5–26 record type, 5–27 run unit, 5–26, 5–28 saving, 5–30 See also Currency indicators, 5–25 set type, 5–27 Database Control System, 1–6 Data Definition Language, 1–5 data item, 5–5 data manipulation language
Database (cont’d) record types, 5–5 RETAINING clause, 5–30 example, 5–31 ROLLBACK statement, 6–3 running an HP COBOL DML program, 1–6 run unit, 5–25 concurrent, 6–2 schema, 5–3 set occurences, 5–9 set relationships, 5–10, 5–11 sets, 5–9 set types, 5–6 simple sets, 5–11, 5–12 simultaneous access to, 6–2 storage address of the record, 5–5 storage schema, 5–3 stream, 5–3 multiple streams, 5–3 subschema, 5–3 SUB-SCHEMA section, 1–5 system-owned sets, 5–11 testing DML programs, 7–1 sample session, 7–2 transactio
EXCLUSIVE RETRIEVAL usage mode, 6–2 EXCLUSIVE UPDATE usage mode, 6–2 J F K FD See File description FD entries, 3–3 FETCH NEXT statement loop, 6–15 FETCH statement, 1–4, 4–31 AT END phrase, 4–17 ON ERROR phrase, 4–16 usage, 6–14 File description clauses of, 3–3 structure of, 3–3 File Section of Data Division, 3–3 FIND ALL option, 6–14 FIND NEXT statement loop, 6–15 FIND statement, 1–3, 4–35 AT END phrase, 4–17 ON ERROR phrase, 4–16 usage, 6–14 FIXED set membership class, 6–8 FOR DB-EXCEPTION statement us
N NEXT, 5–27 Node, 5–1 Null currency indicators, 5–26 O Occurrence owner record, 5–9 record, 5–9 set, 5–6, 5–9 ON ERROR phrase, 4–16, 4–32, 4–37, 7–1 One-to-many relationship, 5–22 OPTIONAL set membership class, 6–8 Oracle CDD/Repository, 1–5, 5–4 Oracle CODASYL DBMS Data Definition Language (DDL), 1–5 Owner record, 5–6 occurrence, 5–9 OWNER test condition, 6–5, 6–6 P PARTS database demonstration package creating, 5–2 loading, 5–2 Place markers database, 1–4 Pointer, 5–25 Position empty, 5–27 PRIOR, 5–27
S Schema, 5–3 Scope terminator, 7–1 Screen Section of Data Division, 3–3 SD entries, 3–3 Selection expression, record, 1–4 Sentences, COBOL See Statements, COBOL Set, 5–9 forked, 5–13 nulling a currency indicator, 6–12 simple, 5–12 single relationship, 5–11 system-owned, 5–11 Set membership class AUTOMATIC, 6–8 FIXED, 6–8 MANDATORY, 6–8 MANUAL, 6–8 OPTIONAL, 6–8 Set membership options and DML verbs, 4–15 Set occurrence, 5–6, 5–9 Set owner access, 1–4 Set type, 5–6 currency indicator, 5–27 current, 5–27 orde
User-defined words (database-related), 2–1 User work area (UWA), 1–3, 1–6 USE statement, 4–62 to 4–65, 7–1 FOR DB-EXCEPTION, 4–18 USING phrase of Procedure Division header, 3–3 Utility Database Query (DBQ), 7–1 DMU, 5–1 UWA See User work area V VALUE IS clause use in Linkage Section, 3–3 use in Working-Storage Section, 3–3 W WHERE clause, 6–17, 7–2 Index–7