[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
DBMS Database Programming Manual


Previous Contents Index

1.2 HP COBOL Data Manipulation Language (DML)

The HP COBOL data manipulation language (DML) is a programming language extension that provides a way for a COBOL application program to access a database. An HP COBOL database application program contains DML statements that tell the Database Control System (DBCS) what to do with specified data; the DBCS provides all database processing control at run time. The four classes of DML statements are data definition, control, retrieval, and update. An explanation of each class follows, together with important definitions of members of that class:

  • Data definition---These entries define the specific part of the database to be accessed by the application program and any keeplists needed to navigate through it. The entries also result in the creation of a database user work area (UWA). Transfer of data between your program and the database takes place in the UWA. Your program delivers data for the DBCS to this area; it is here that the DBCS places data requested from the database for retrieval to your program.
    SUB-SCHEMA SECTION Is the first section of the Data Division. It contains two paragraphs: the Subschema entry (DB) and the Keeplist Description entry (LD).
    DB Names the target subschema, translates subschema record descriptions to compatible HP COBOL record descriptions, and creates a user work area (UWA).
    LD Names a keeplist to help you navigate through the database.

    For more information on these entries see Chapter 3, Data Division.
  • Control---The DML control functions tell the DBCS when and how to begin or end a database transaction.
    COMMIT Terminates your transaction, makes permanent all changes made to the database since the last quiet point, and establishes a new quiet point for the run unit.
    READY Prepares selected realms for use.
    ROLLBACK Ends your transaction, cancels all changes made to the database since the start of your transaction, empties all keeplists, and nulls all currency indicators.
  • Retrieval---The DML retrieval functions are used to find a record in the database and, if necessary, retain the record in the user work area (UWA) for later use.
    FIND Locates a record in the database.
    FIND ALL Locates all specified records in the database and puts them in a keeplist.
    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. By using a Record Selection Expression in a FIND or FETCH statement, a program has four formats to choose from: (1) database key identifier access, (2) set owner access, (3) record search access, or (4) DB-KEY access. Chapter 4, Procedure Division, explains these in detail.
    A COBOL program can sequentially search the database or individual realm. In all cases, once a record is found by the COBOL application program, the DBCS sets a currency indicator to hold the database key value of that record or the position of that record. The COBOL program can indirectly use this value in KEEP, FIND ALL, or FREE statements or use the RETAINING option as a placemarker to help the program navigate through the database.
  • Update---These functions allow the creation, modification, and deletion of database records.
    CONNECT Makes a record a member in one or more sets.
    DISCONNECT Removes a record from one or more sets.
    ERASE Deletes records from the database.
    MODIFY Changes the contents of a record in the database.
    RECONNECT Moves a record from one occurrence of a set type to another (possibly the same) occurrence.
    STORE Adds a record to the database.

Chapter 4 discusses the effects of the schema data definition language (DDL) INSERTION and RETENTION options on each of the DML update verbs.

Once a record has been located by a COBOL program, it can be changed or even erased from the database. DML programming operations also change the fundamental relationships within sets, causing records to change as well. For example, each set is owned by a record or Oracle CODASYL DBMS itself. If the program erases a record that is the owner of the set, all member records may also be deleted.

Section 4.5 contains more information on DML statements, database conditional expressions, and the special registers DB-CONDITION, DB-CURRENT-RECORD-NAME, DB-CURRENT-RECORD-ID, DB-UWA, and DB-KEY.

1.3 Creating an HP COBOL DML Program

When you create an HP COBOL DML program, you must include the SUB-SCHEMA SECTION entry as the first section in the Data Division. The SUB-SCHEMA SECTION is followed by a DB statement and any LD statements. The Procedure Division contains all occurrences of the DML verbs.

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. Therefore, when the HP COBOL compiler retrieves the subschema definition from Oracle CDD/Repository, it translates the file into an internal form acceptable to the HP COBOL compiler.

If the translation results in compiler errors, they will probably be fatal.

You should alert your DBA to any errors resulting from a DB statement.

You can define the logical name CDD$DEFAULT as the starting schema node in Oracle CDD/Repository. There is only one logical name translation in the DB statement for schema-name. If you do not define it, CDD$TOP is the default.

Note

You must recompile an HP COBOL DML program each time the subschema referenced by a DB statement is created. At compile time, the date and time of subschema creation (date and time stamps) are included with the translated subschema record definitions. If you do not recompile, your program will receive a fatal error at run time.


Previous Next Contents Index