In general, database processing is transaction oriented. Even batch jobs should be pseudo-transactional to allow for checkpointing. An application program accesses one or more database records for each transaction it processes. There are two basic types of DL/I application programs:
A direct access program accesses, for every input transaction, segments in one or more database records. These accesses are based on database record and segment identification. This identification is essentially derived from the transaction input and is normally the root-key value and additional (key) field values of dependent segments. For more complex transactions, segments can be accessed in several DL/I databases concurrently. A sequential access program accesses sequentially selected segments of all of a consecutive subset of a particular database. The sequence is usually determined by the key of the root segment. A sequential access program can also access other databases, but those accesses are direct, unless the root keys of both databases are the same. A DL/I application program normally processes only particular segments of the DL/I databases. The portion that a given program processes is called an application data structure. This application data structure is defined in the program specification block (PSB). An application data structure always consists of one or more hierarchical data structures, each of which is derived from a DL/I physical or logical database. At execution time, each application program uses one PSB and it is usually a different PSB than those used by other application programs. Application Programming Interfaces to IMSDuring initialization, both the application program and its associated PSB are loaded from their respective libraries by the IMS system The DL/I modules, which reside together with the application program in one region, interpret and execute database call requests issued by the program. Calls to DL/IA call request is composed of a CALL statement with an argument list. The argument list specifies the processing function to be performed, the hierarchic path to the segment to be accessed, and the segment occurrence of that segment. One segment can be operated upon with a single DL/I call. However, a single call never returns more than one occurrence of one segment type. The arguments contained within any DL/I call request are defined in "Calls to IMS" on page 227. The following code is a sample basic CALL statement for COBOL: CALL 'CBLTDLI' USING function,PCB-name,I/O Area, SSA1,...SSAn. Table 15-1 describes some of the components of the CALL statement: the basic DL/I call functions to request DL/I database services.
The DL/I calls listed in Table 15-1 fall into four segment access categories. Table 15-2 describes these categories.
In addition to the database calls listed in Table 15-1 and Table 15-2, there are also system service calls. System service calls are used to request system services such as checkpoints and restarts. All the calls in Table 15-1 and Table 15-2 are discussed in detail in the following sections. Segment Search Arguments (SSAs)For each segment accessed in a hierarchical path, one segment search argument (SSA) can be provided. The purpose of the SSA is to identify by segment name and, optionally, by field value the segment to be accessed. The basic function of the SSA permits the application program to apply three different kinds of logic to a call:
SSA names represent the fourth (fifth for PL/I) through last arguments (SSA1 through SSAn) in the call statement. There can be zero or one SSA per level, and, because DL/I permits a maximum of 15 levels per database, a call can contain from zero to 15 SSA names. In the code examples in this section, an SSA consists of one, two, or three of the following elements:
Qualification of SSAsJust as calls are qualified by the presence of an SSA, SSAs are categorized as either qualified or unqualified, depending on the presence or absence of a qualification statement. Command codes can be included in or omitted from either qualified or unqualified SSAs. In its simplest form, an SSA is unqualified and consists only of the name of a specific segment type as defined in the DBD. In this simple form, the SSA provides DL/I with enough information to define the segment type required by the call. In the following example, the last character is a blank, which indicates the SSA is unqualified: SEGNAME Qualified SSAs, which are optional, contain a qualification statement composed of three parts:
DL/I uses the information in the qualification statement to test the value of the segment's key or data fields within the database, and thus to determine whether the segment meets the user's specifications. Using this approach, DL/I performs the database segment searching. The program need process only those segments that precisely meet some logical criteria. For example: SEGNAME(fieldxxx>=value) The qualification statement test is terminated either when the test is satisfied by an occurrence of the segment type, or when DL/I determines that the request cannot be satisfied. Command Codes in SSAsBoth unqualified and qualified SSAs can contain one or more optional command codes which specify functional variations applicable to the call function or the segment qualification. For more information about command codes, see "Calls with Command Codes" on page 255. General Characteristics of SSAsGeneral characteristics of segment search arguments:
Examples of SSAs are given with the sample calls at each DL/I call discussion in "Processing a Single Database Record." |