Programming in the CA IDMS Environment (COBOL)
CA IDMS DML statements are divided into two categories:
CA IDMS DML statements are divided into two categories:
- Database statementsperform retrieval and update functions in the batch and the online environments. Database statements fall into one of the following categories:
- Navigational statementsaccess database records and sets, one record at a time.
- LRF statementsaccess groups of database records by using the Logical Record Facility (LRF).
- SQL statementsaccess groups of database records by using the Structured Query Language (SQL).
- Data communications statements(also known as online statements) request data communications services, such as for online programs.
You can include database statements in batch programs or can combine them with data communications statements in online programs that require database access. See the following discussions about accessing the database by using DML statements and additional considerations for coding online programs.
Accessing the Database
In CA IDMS, the database can be accessed by using navigational, LRF DML, or SQL DML statements:
- Navigational statements are used with a subschema usage mode of DML or MIXED.
- LRF DML statements are used with a subschema usage mode of LR or MIXED.
- SQL DML statements access records without reference to subschemas.
Some statements, such as BIND RUN-UNIT, READY, and FINISH, are used in all three environments. They are noted in the individual descriptions of each DML statement in Data Manipulation Language Statements.
Navigational DML statements access the database records and sets one record at a time, checking and maintaining currency to ensure correct results. To use navigational DML statements, you must have a thorough knowledge of the database structure. For an example of a data structure diagram, see the EMPLOYEE Database Definition.
Navigational DML statements provide the following advantages:
- Control over error checking—You can check the result of each navigational statement, enabling more thorough error detection.
- Flexibility in choosing a database access strategy—You can enter the database sequentially (area sweep), by using a symbolic key value (CALC), or by using a database key value (DIRECT).
Navigational DML statements are grouped into the following categories:
- Control statementsinitiate and terminate processing, effect recovery, prevent concurrent updates, and evaluate set conditions.
- Retrieval statementslocate data in the database and make it available to the application program.
- Modification statementsupdate the database.
- Accept statementspass database keys, storage address information, and statistics to the program.
LRF DML Statements
LRF DML statements use the Logical Record Facility (LRF) to access database records. LRF lets you access fields from multiple database records as if they were data fields in a single record. LRF DML statements let you specify selection criteria (by using the WHERE clause) that enable you to access only the needed logical records.
LRF DML statements provide the following advantages:
- Easy access to database records—You do not have to be familiar with database structure. Your programs do not have to include database navigation logic.
- Data flexibility—Modification and recompilation of LRF programs are not necessarily required when the physical or logical structure of the database is changed.
- Run-time efficiency—LRF minimizes communication between the program and the DBMS.
The following LRF DML statements are available:
- ERASEdeletes a logical record as specified in the path definition.
- MODIFYmodifies a logical record as specified in the path definition.
- OBTAINretrieves a logical record as specified in the path definition.
- STOREstores a new logical record as specified in the path definition.
SQL DML Statements
You can use SQL DML to access the same databases that you access using navigational DML. Also, you can use SQL DML to access databases that have been defined using SQL DDL. You do not have to be familiar with database structure, and your programs do not have to include database navigation logic.
You can perform the following functions with SQL DML statements:
Programming in the Online Environment
The CA IDMS/DC system is fully integrated with the CA IDMS DBMS and the data dictionary. You can request data communications and database services through the standard subroutine calls that the precompiler generates from DML statements.
The following figure illustrates a typical stream of online DML statements in a COBOL program. This example maps in a user-specified employee ID, retrieves and displays the specified information, and performs a DC RETURN that names TSK02 as the next task to perform:
PROCEDURE DIVISION. BIND MAP EMPMAPLR. BIND MAP EMPMAPLR RECORD EMPLOYEE. ACCEPT TASK CODE INTO TASK-CODE-IN. IF TASK-CODE-IN = 'TSK01' GO TO INITIAL-MAPOUT. MAP IN USING EMPMAPLR. . . navigational, LRF, or SQL database DML statements . . MAP OUT USING EMPMAPLR OUTPUT DATA IS YES MESSAGE IS DISPLAY-MESSAGE LENGTH 80. DC RETURN NEXT TASK CODE 'TSK02'.
Online DML statements, which request CA IDMS to perform data communications services, are grouped into the following categories:
- Program management statementsgovern the flow of control and abend processing.
- Storage management statementsallocate and release variable storage.
- Task management statementsprovide runtime services that enhance control over task processing.
- Time management statementsobtain the time and date, and define time-related events.
- Scratch management statementscreate, delete, or retrieve records from the scratch area.
- Queue managementstatements create, delete, or retrieve records in a queue area.
- Terminal management statementstransfer data between the application program and a terminal.
- Utility function statementsretrieve task-related information or statistics, send messages, and monitor access to database records.
- Recovery statementsperform functions relating to database, scratch, and queue area recovery when a system failure occurs.