CONTENTS Title Page Copyright Page Preface 1 Introduction to Programming in DEC DBMS 1.1 Getting the Information Necessary to Write a Program 1.2 Selecting a Usage Mode 1.2.1 The Volume of Data the Program Will Use 1.2.2 The Need for Fast Performance 1.2.3 Your Ability to Share Data 1.3 Understanding the Subschema 1.3.1 Subschema Diagram 1.3.2 Subschema Listing 1.3.3 Written Subschema Explanation 2 Using the Database Query Utility 2.1 Beginning and Ending a DBQ Session 2.2 Getting Help in DBQ 2.3 Binding to a Database in DBQ 2.4 Displaying Information About the Database 2.5 Beginning a Transaction 2.6 Ending a Transaction 2.7 Ending Database Access Between or After Transactions 2.8 Locating and Retrieving Records 2.8.1 Using Data Item Values to Retrieve Records 2.8.1.1 Finding an Exact Match 2.8.1.2 Finding Values Based on Boolean Expressions 2.8.2 Using a Record and Its Relationships 2.8.3 Using Data Item Values and Set Relationships 2.8.3.1 Retrieving Records from Sequential or CHAIN Sets 2.8.3.2 Retrieving Records in Hashed or CALC Sets 2.8.3.3 Retrieving Records in INDEX Sets 2.8.4 Using Loops to Walk Through Sets 2.8.5 Summary of Retrieval in Sets 2.9 Moving Through a Database 2.9.1 The Current Record 2.9.2 Null or Position Currency 2.9.3 Maintaining Currency 2.9.4 Rules for Using Currency Indicators 2.9.5 The Currency Display Legend 2.9.6 Manipulating Currency Indicators in Database Access 2.10 Modifying Existing Records 2.11 Adding Records to a Database and to Sets 2.12 Removing Records from a Database or from Sets 2.12.1 Erasing Records 2.12.2 Moving Records to Other Set Occurrences 2.12.3 Disconnecting Records from Sets 2.13 Summary of Membership Characteristics 2.14 Editing Within the DBQ Utility 3 Embedding DML Statements 3.1 Using DML Statements 3.2 Using Callable DBQ Routines 3.2.1 Creating a User Work Area 3.2.2 Calling a DBQ Routine 3.3 Compiling, Linking, and Running Programs 3.3.1 Compiling DML Programs 3.3.1.1 Specifying the Host Language 3.3.1.2 Specifying the DML Prefix Character 3.3.1.3 Specifying Whether or Not Intermediate Files Are Compiled 3.3.1.4 Specifying Whether or Not Comments Are Included in Intermediate Files 3.3.1.5 Specifying Whether or Not Intermediate Files Are Deleted 3.3.1.6 Specifying the Options for Intermediate Files 3.3.1.7 Specifying the Directory for the Object File 3.3.1.8 Specifying Whether or Not Error Trapping Is Enabled 3.3.1.9 Defining Symbols for DML Commands 3.3.1.10 DML Precompiler Error Messages 3.3.2 Compiling Callable DBQ Programs 3.3.2.1 VAX Ada 3.3.2.2 VAX BASIC 3.3.2.3 VAX BLISS 3.3.2.4 VAX C 3.3.2.5 VAX COBOL 3.3.2.6 VAX DIBOL 3.3.2.7 VAX FORTRAN 3.3.2.8 VAX MACRO 3.3.2.9 VAX Pascal 3.3.2.10 VAX PL/I 3.4 Linking and Running Programs 3.5 Using the Sample Application Programs 3.5.1 VAX Ada 3.5.2 VAX BASIC 3.5.3 VAX BLISS 3.5.4 VAX C 3.5.5 VAX COBOL 3.5.6 VAX DIBOL 3.5.7 VAX FORTRAN 3.5.8 VAX MACRO 3.5.9 VAX Pascal 3.5.10 VAX PL/I 4 Programming the Two-Phase Commit Protocol 4.1 Deciding to Use Two-Phase Commit 4.2 Programming for Two-Phase Commit 4.2.1 Starting a Distributed Transaction 4.2.2 Joining a Distributed Transaction 4.2.3 Ending a Distributed Transaction 4.3 Handling Errors 5 Programming Topics 5.1 Invoking a Database 5.2 Finding and Fetching Records 5.2.1 Creating a Bill of Materials 5.2.2 Fetching Records Within a MANUAL OPTIONAL Set 5.2.3 Fetching Records Within a Forked Set 5.3 Storing New Records 5.3.1 Inserting Stored Records into SYSTEM-Owned Sets 5.3.2 Inserting Stored Records into Forked Sets 5.4 Modifying Records 5.5 Erasing Records 5.6 Condition Tests 5.7 Using String Concatenation Instead of Passing Variables 5.8 Error Handling 5.8.1 Testing the Program Logic 5.8.2 Trapping Errors 5.8.2.1 Trapping Errors Globally 5.8.2.2 Trapping Errors Line by Line 5.8.3 Handling Errors 5.9 Supported Data Types 6 Writing VAX Ada Programs with DEC DBMS 6.1 Invoking a Database 6.2 Finding and Fetching Records 6.2.1 Creating a Bill of Materials 6.2.2 Fetching a Record Within a MANUAL OPTIONAL Set 6.2.3 Fetching a Record Within a Forked Set 6.3 Storing New Records 6.3.1 Inserting Stored Records into SYSTEM-Owned Sets 6.3.2 Inserting Stored Records into Forked Sets 6.4 Modifying Records 6.5 Erasing Records 6.6 Using String Concatenation Instead of Passing Variables 6.7 Handling Errors 6.8 Condition Tests 6.9 Supported Data Types 7 Writing VAX BASIC Programs with DEC DBMS 7.1 Invoking a Database 7.2 Finding and Fetching Records 7.2.1 Creating a Bill of Materials 7.2.2 Fetching a Record Within a MANUAL OPTIONAL Set 7.2.3 Fetching a Record Within a Forked Set 7.3 Storing New Records 7.3.1 Inserting Stored Records into SYSTEM-Owned Sets 7.3.2 Inserting Stored Records into Forked Sets 7.4 Modifying Records 7.5 Erasing Records 7.6 Using String Concatenation Instead of Passing Variables 7.7 Handling Errors 7.8 Condition Tests 7.9 Supported Data Types 8 Writing VAX BLISS Programs with DEC DBMS 8.1 Invoking a Database 8.2 Finding and Fetching Records 8.2.1 Creating a Bill of Materials 8.2.2 Fetching a Record Within a MANUAL OPTIONAL Set 8.2.3 Fetching a Record Within a Forked Set 8.3 Storing New Records 8.3.1 Inserting Stored Records into SYSTEM-Owned Sets 8.3.2 Inserting Stored Records into Forked Sets 8.4 Modifying Records 8.5 Erasing Records 8.6 Using String Concatenation Instead of Passing Variables 8.7 Handling Errors 8.8 Condition Tests 8.9 Supported Data Types 9 Writing VAX C Programs with DEC DBMS 9.1 Invoking a Database 9.2 Finding and Fetching Records 9.2.1 Creating a Bill of Materials 9.2.2 Fetching a Record Within a MANUAL OPTIONAL Set 9.2.3 Fetching a Record Within a Forked Set 9.3 Storing New Records 9.3.1 Inserting Stored Records into SYSTEM-Owned Sets 9.3.2 Inserting Stored Records into Forked Sets 9.4 Modifying Records 9.5 Erasing Records 9.6 Using String Concatenation Instead of Passing Variables 9.7 Handling Errors 9.8 Condition Tests 9.9 Supported Data Types 10 Writing VAX COBOL Programs with DEC DBMS 10.1 Invoking a Database 10.2 Finding and Fetching Records 10.2.1 Creating a Bill of Materials 10.2.2 Fetching a Record Within a MANUAL OPTIONAL Set 10.2.3 Fetching a Record Within a Forked Set 10.3 Storing New Records 10.3.1 Inserting Stored Records into SYSTEM-Owned Sets 10.3.2 Inserting Stored Records into Forked Sets 10.4 Modifying Records 10.5 Erasing Records 10.6 Using String Concatenation Instead of Passing Variables 10.7 Handling Errors 10.8 Condition Tests 10.9 Supported Data Types 11 Writing VAX DIBOL Programs with DEC DBMS 11.1 Invoking a Database 11.2 Finding and Fetching Records 11.2.1 Creating a Bill of Materials 11.2.2 Fetching a Record Within a MANUAL OPTIONAL Set 11.2.3 Fetching a Record Within a Forked Set 11.3 Storing New Records 11.3.1 Inserting Stored Records into SYSTEM-Owned Sets 11.3.2 Inserting Stored Records into Forked Sets 11.4 Modifying Records 11.5 Erasing Records 11.6 Using String Concatenation Instead of Passing Variables 11.7 Handling Errors 11.8 Condition Tests 11.9 Supported Data Types 12 Writing VAX FORTRAN Programs with DEC DBMS 12.1 Invoking a Database 12.2 Finding and Fetching Records 12.2.1 Creating a Bill of Materials 12.2.2 Fetching a Record Within a MANUAL OPTIONAL Set 12.2.3 Fetching a Record Within a Forked Set 12.3 Storing New Records 12.3.1 Inserting Stored Records into SYSTEM-Owned Sets 12.3.2 Inserting Stored Records into Forked Sets 12.4 Modifying Records 12.5 Erasing Records 12.6 Using String Concatenation Instead of Passing Variables 12.7 Handling Errors 12.8 Condition Tests 12.9 Supported Data Types 13 Writing VAX MACRO Programs with DEC DBMS 13.1 Invoking a Database 13.2 Finding and Fetching Records 13.2.1 Creating a Bill of Materials 13.2.2 Fetching a Record Within a MANUAL OPTIONAL Set 13.2.3 Fetching a Record Within a Forked Set 13.3 Storing New Records 13.3.1 Inserting Stored Records into SYSTEM-Owned Sets 13.3.2 Inserting Stored Records into Forked Sets 13.4 Modifying Records 13.5 Erasing Records 13.6 Using String Concatenation Instead of Passing Variables 13.7 Handling Errors 13.8 Condition Tests 13.9 Supported Data Types 14 Writing VAX Pascal Programs with DEC DBMS 14.1 Invoking a Database 14.2 Finding and Fetching Records 14.2.1 Creating a Bill of Materials 14.2.2 Fetching a Record Within a MANUAL OPTIONAL Set 14.2.3 Fetching a Record Within a Forked Set 14.3 Storing New Records 14.3.1 Inserting Stored Records into SYSTEM-Owned Sets 14.3.2 Inserting Stored Records into Forked Sets 14.4 Modifying Records 14.5 Erasing Records 14.6 Using String Concatenation Instead of Passing Variables 14.7 Handling Errors 14.8 Condition Tests 14.9 Supported Data Types 15 Writing VAX PL/I Programs with DEC DBMS 15.1 Invoking a Database 15.2 Finding and Fetching Records 15.2.1 Creating a Bill of Materials 15.2.2 Fetching a Record Within a MANUAL OPTIONAL Set 15.2.3 Fetching a Record Within a Forked Set 15.3 Storing New Records 15.3.1 Inserting Stored Records into SYSTEM-Owned Sets 15.3.2 Inserting Stored Records into Forked Sets 15.4 Modifying Records 15.5 Erasing Records 15.6 Using String Concatenation Instead of Passing Variables 15.7 Handling Errors 15.8 Condition Tests 15.9 Supported Data Types A PARTS Database Subschema A.1 PARTS Bachman Diagram A.2 PARTSS1 Subschema A.3 PARTSS2 Subschema A.4 PARTSS3 Subschema A.5 PARTSS4 Subschema A.6 PARTSS5 Subschema B Finding the Sample Programs C The Two-Phase Commit Protocol C.1 Distributed Transactions C.2 Two-Phase Commit Protocol C.3 Walkthrough of a Two-Phase Commit Transaction D VAX FORTRAN Example of Two-Phase Commit E VAX COBOL Example of Two-Phase Commit EXAMPLES 4-1 MAIN.PAS 4-2 DB1SUB.PAS 4-3 DB2SUB.PAS 5-1 BOM_QUERIES Module 5-2 BOM_QUERIES_DML Module 5-3 PARTS_BY_EMPLOYEE Module 5-4 PARTS_BY_EMPLOYEE_DML Module 5-5 VENDOR_BY_PART Module 5-6 VENDOR_BY_PART_DML Module 5-7 ADD_PARTS Module 5-8 ADD_PARTS_DML Module 5-9 ADD_SUPPLY Module 5-10 ADD_SUPPLY_DML Module 5-11 ADD_QUOTE Module 5-12 ADD_QUOTE_DML Module 5-13 MODIFY_PARTS Module 5-14 MODIFY_PARTS_DML Module 5-15 DELETE_PARTS Module 5-16 DELETE_PARTS_DML Module 5-17 BIDS_BY_PRICE Module 5-18 BIDS_BY_PRICE_DML Module 5-19 ERROR_HANDLER Module 6-1 BOM_QUERIES Module 6-2 BOM_QUERIES_DML Module 6-3 PARTS_BY_EMPLOYEE Module 6-4 PARTS_BY_EMPLOYEE_DML Module 6-5 VENDOR_BY_PART Module 6-6 VENDOR_BY_PART_DML Module 6-7 ADD_PARTS Module 6-8 ADD_PARTS_DML Module 6-9 ADD_SUPPLY Module 6-10 ADD_SUPPLY_DML Module 6-11 ADD_QUOTE Module 6-12 ADD_QUOTE_DML Module 6-13 MODIFY_PARTS Module 6-14 MODIFY_PARTS_DML Module 6-15 DELETE_PARTS Module 6-16 DELETE_PARTS_DML Module 6-17 BIDS_BY_PRICE Module 6-18 BIDS_BY_PRICE_DML Module 6-19 ERROR_HANDLER Module 7-1 BOM_QUERIES Module 7-2 BOM_QUERIES_DML Module 7-3 PARTS_BY_EMPLOYEE Module 7-4 PARTS_BY_EMPLOYEE_DML Module 7-5 VENDOR_BY_PART Module 7-6 VENDOR_BY_PART_DML Module 7-7 ADD_PARTS Module 7-8 ADD_PARTS_DML Module 7-9 ADD_SUPPLY Module 7-10 ADD_SUPPLY_DML Module 7-11 ADD_QUOTE Module 7-12 ADD_QUOTE_DML Module 7-13 MODIFY_PARTS Module 7-14 MODIFY_PARTS_DML Module 7-15 DELETE_PARTS Module 7-16 DELETE_PARTS_DML Module 7-17 BIDS_BY_PRICE Module 7-18 BIDS_BY_PRICE_DML Module 7-19 ERROR_HANDLER Module 8-1 BOM_QUERIES Module 8-2 BOM_QUERIES_DML Module 8-3 PARTS_BY_EMPLOYEE Module 8-4 PARTS_BY_EMPLOYEE_DML Module 8-5 VENDOR_BY_PART Module 8-6 VENDOR_BY_PART_DML Module 8-7 ADD_PARTS Module 8-8 ADD_PARTS_DML Module 8-9 ADD_SUPPLY Module 8-10 ADD_SUPPLY_DML Module 8-11 ADD_QUOTE Module 8-12 ADD_QUOTE_DML Module 8-13 MODIFY_PARTS Module 8-14 MODIFY_PARTS_DML Module 8-15 DELETE_PARTS Module 8-16 DELETE_PARTS_DML Module 8-17 BIDS_BY_PRICE Module 8-18 BIDS_BY_PRICE_DML Module 8-19 ERROR_HANDLER Module 9-1 BOM_QUERIES Module 9-2 BOM_QUERIES_DML Module 9-3 PARTS_BY_EMPLOYEE Module 9-4 PARTS_BY_EMPLOYEE_DML Module 9-5 VENDOR_BY_PART Module 9-6 VENDOR_BY_PART_DML Module 9-7 ADD_PARTS Module 9-8 ADD_PARTS_DML Module 9-9 ADD_SUPPLY Module 9-10 ADD_SUPPLY_DML Module 9-11 ADD_QUOTE Module 9-12 ADD_QUOTE_DML Module 9-13 MODIFY_PARTS Module 9-14 MODIFY_PARTS_DML Module 9-15 DELETE_PARTS Module 9-16 DELETE_PARTS_DML Module 9-17 BIDS_BY_PRICE Module 9-18 BIDS_BY_PRICE_DML Module 9-19 ERROR_HANDLER Module 10-1 BOM_QUERIES Module 10-2 BOM_QUERIES_DML Module 10-3 PARTS_BY_EMPLOYEE Module 10-4 PARTS_BY_EMPLOYEE_DML Module 10-5 VENDOR_BY_PARTS Module 10-6 VENDOR_BY_PARTS_DML Module 10-7 ADD_PARTS Module 10-8 ADD_PARTS_DML Module 10-9 ADD_SUPPLY Module 10-10 ADD_SUPPLY_DML Module 10-11 ADD_QUOTE Module 10-12 ADD_QUOTE_DML Module 10-13 MODIFY_PARTS Module 10-14 MODIFY_PARTS_DML Module 10-15 DELETE_PARTS Module 10-16 DELETE_PARTS_DML Module 10-17 BIDS_BY_PRICE Module 10-18 BIDS_BY_UNIT_PRICE_DML Module 10-19 ERROR-HANDLER Module 11-1 BOM_QUERIES Module 11-2 BOM_QUERIES_DML Module 11-3 PARTS_BY_EMPLOYEE Module 11-4 PARTS_BY_EMPLOYEE_DML Module 11-5 VENDOR_BY_PART Module 11-6 VENDOR_BY_PART_DML Module 11-7 ADD_PARTS Module 11-8 ADD_PARTS_DML Module 11-9 ADD_SUPPLY Module 11-10 ADD_SUPPLY_DML Module 11-11 ADD_QUOTE Module 11-12 ADD_QUOTE_DML Module 11-13 MODIFY_PARTS Module 11-14 MODIFY_PARTS_DML Module 11-15 DELETE_PARTS Module 11-16 DELETE_PARTS_DML Module 11-17 BIDS_BY_PRICE Module 11-18 BIDS_BY_PRICE_DML Module 11-19 ERROR_HANDLER Module 12-1 Common Block 12-2 BOM_QUERIES Module 12-3 BOM_QUERIES_DML Module 12-4 PARTS_BY_EMPLOYEE Module 12-5 PARTS_BY_EMPLOYEE_DML Module 12-6 VENDOR_BY_PART Module 12-7 VENDOR_BY_PART_DML Module 12-8 ADD_PARTS Module 12-9 ADD_PARTS_DML Module 12-10 ADD_SUPPLY Module 12-11 ADD_SUPPLY_DML Module 12-12 ADD_QUOTE Module 12-13 ADD_QUOTE_DML Module 12-14 MODIFY_PARTS Module 12-15 MODIFY_PARTS_DML Module 12-16 DELETE_PARTS Module 12-17 DELETE_PARTS_DML Module 12-18 BIDS_BY_PRICE Module 12-19 BIDS_BY_PRICE_DML Module 12-20 ERROR_HANDLER Module 13-1 BOM_QUERIES Module 13-2 BOM_QUERIES_DML Module 13-3 PARTS_BY_EMPLOYEE Module 13-4 PARTS_BY_EMPLOYEE_DML Module 13-5 VENDOR_BY_PART Module 13-6 VENDOR_BY_PART_DML Module 13-7 ADD_PARTS Module 13-8 ADD_PARTS_DML Module 13-9 ADD_SUPPLY Module 13-10 ADD_SUPPLY_DML Module 13-11 ADD_QUOTE Module 13-12 ADD_QUOTE_DML Module 13-13 MODIFY_PARTS Module 13-14 MODIFY_PARTS_DML Module 13-15 DELETE_PARTS Module 13-16 DELETE_PARTS_DML Module 13-17 BIDS_BY_PRICE Module 13-18 BIDS_BY_PRICE_DML Module 13-19 ERROR_HANDLER Module 14-1 BOM_QUERIES Module 14-2 BOM_QUERIES_DML Module 14-3 PARTS_BY_EMPLOYEE Module 14-4 PARTS_BY_EMPLOYEE_DML Module 14-5 VENDOR_BY_PART Module 14-6 VENDOR_BY_PART_DML Module 14-7 ADD_PARTS Module 14-8 ADD_PARTS_DML Module 14-9 ADD_SUPPLY Module 14-10 ADD_SUPPLY_DML Module 14-11 ADD_QUOTE Module 14-12 ADD_QUOTE_DML Module 14-13 MODIFY_PARTS Module 14-14 MODIFY_PARTS_DML Module 14-15 DELETE_PARTS Module 14-16 DELETE_PARTS_DML Module 14-17 BIDS_BY_PRICE Module 14-18 BIDS_BY_PRICE_DML Module 14-19 ERROR_HANDLER Module 15-1 PL/I Declarations 15-2 BOM_QUERIES Module 15-3 BOM_QUERIES_DML Module 15-4 PARTS_BY_EMPLOYEE Module 15-5 PARTS_BY_EMPLOYEE_DML Module 15-6 VENDOR_BY_PARTS Module 15-7 VENDOR_BY_PART_DML Module 15-8 ADD_PARTS Module 15-9 ADD_PARTS_DML Module 15-10 ADD_SUPPLY Module 15-11 ADD_SUPPLY_DML Module 15-12 ADD_QUOTE Module 15-13 ADD_QUOTE_DML Module 15-14 MODIFY_PARTS Module 15-15 MODIFY_PARTS_DML Module 15-16 DELETE_PARTS Module 15-17 DELETE_PARTS_DML Module 15-18 BIDS_BY_PRICE Module 15-19 BIDS_BY_PRICE_DML Module 15-20 ERROR_HANDLER Module D-1 MAIN.FOR D-2 DB1SUB D-3 DB2SUB E-1 TWOPC_MAIN.COB E-2 TWOPC_EAST.COB E-3 TWOPC_WEST.COB FIGURES 1-1 Usage Mode Conflicts Chart 1-2 Bachman Diagram of the PARTS Database 2-1 Currency Diagram on VT2xx Terminal 2-2 Pointer Clusters 2-3 Physical Collection of Records 2-4 Database Keys 2-5 Currency Display 2-6 Positional Currency Display 2-7 Insertion, Retention, and Deletion Operations Chart 3-1 Compilation Process A-1 Bachman Diagram of the PARTS Database C-1 Example of A Distributed Transaction C-2 Starting a Distributed Transaction C-3 Ending a Distributed Transaction C-4 Prepare Phase of the Two-Phase Commit Protocol C-5 Resource Manager Executes Prepare Phase C-6 Participants Vote C-7 Coordinator Writes Commit Record C-8 Executing the Commit Phase C-9 Resource Managers Execute the Commit Phase C-10 Acknowledging the Commit TABLES 2-1 Relational Operators 5-1 Status Returned to DML$VALUE or FDM$VALUE 5-2 Constants Declared by the DML Precompiler 6-1 VAX Ada Data Types 7-1 VAX BASIC Data Types 8-1 VAX BLISS Data Types 9-1 VAX C Data Types 10-1 VAX COBOL Data Types 11-1 VAX DIBOL Data Types 12-1 VAX FORTRAN Data Types 13-1 VAX MACRO Data Types 14-1 VAX Pascal Data Types 15-1 VAX PL/I Data Types