Академический Документы
Профессиональный Документы
Культура Документы
Objectives
To create awareness about the IMS DB technology and how it is used to perform data base operations. Target audience :- people who are relatively new to the IMS DB Technology.
Prerequisites
Knowledge of COBOL Basic knowledge of data base management concepts
Course Outline
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. An Introduction to DL/I Data Bases DL/I Programs and Control Blocks COBOL Basics for Processing a DL/I Data Base Segment Search Arguments : How to use them Data retrieval from an IMS Data Base Adding and Updating Data to a Data Base Secondary Indexing Logical Data Bases Recovery and Restart DL/I Data Base Organizations Advanced DL/I features
References
IMS for the COBOL Programmer
Part 1: Data base processing with IMS/VS and DL/I DOS/VS By Steve Eckols
IBM Redbooks : IMS Primer
Hierarchical Structures
In a DL/I data base, data elements are organized in a hierarchical structure. Some data elements are dependent on others.
DL/I supports hierarchies that are difficult to implement with standard files.
A grouping of data The unit of data that DL/I transfers to and from your program in an I/O operation. Consists of one or more fields
Segment Type
A category of data There can be a maximum of 255 segment types and 15 levels in one data base
House Number
Street Name
City
State
Country
Zip Code
Segment Occurrence
One specific segment of a particular type containing user data
Note: Within a data base there is only one of each segment type- its part of the data bases definitionbut there can be an unlimited number of occurrences of each segment type. The word segment is used to mean either segment type or segment occurrence and usually the meaning is clear from the context
Vendor
Item
Stock Location Fig 1.4 The hierarchical structure of the Inventory data base with three segment types
Each occurrence of the root segment plus all the segment occurrences that are subordinate to it make up one data base record. Every data base Vendor 2 Vendor 1 record has one and only one root segment, Item 1 subordinate Item 2 although it may have any number of Data base Record 2 Item 1 segment occurrences Loc 2 Loc 2
Loc 1 Loc 1 Fig 1.6 Two Loc 5 data base records from the Inventory data base Loc 4 Loc 3 Loc 2 Loc 1
A segment other than the root segment in a data base record Accessible only through one or more parent segments
Parent Segment
The field DLI uses to maintain segments in ascending sequence Only a single field within a segment Segments need not necessarily require a key field If in a root segment, key field uniquely identifies the record
Additional Search fields
Ship-to
Vendor Item
Buyer
Receivable
Stock Location
Fig 1.7 A logical relationship can connect two data bases
Payment
Adjustment
Line Item
In Fig 1.7, the line item segment is the logical child segment (or just logical child) of the item segment. Likewise, the item segment is the logical parent segment (or just logical parent) of the line item segment
Sequential Processing
Item 2 Item 1 Loc 2 Data base Record 1 Loc 5 Loc 4 Loc 3 Loc 2 Loc 1 Fig 1.8 Sequential processing Loc 1
Loc 2 Loc 1
Basic DL/I Data Base Processing Random (Direct) Processing (contd.) Key (sequence) field required
Concatenated Key
Completely identifies the path from the root segment to the segment you want to retrieve.
Vendor 1 Vendor 2
Loc 2 Loc 1
Data Base
Application Program
Application Program
DL/I
(eg. VSAM)
Standard COBOL statements (like READ / WRITE) invoke the appropriate access method (like VSAM) Format of the record as processed by the program should be the same as the format of the record in the file
DL/I data base processing
DLI - Interface between application program and the access method CALL statement to invoke DL/I Parameters passed by the CALL tell DL/I what operation to perform DL/I invokes a standard access method- usually VSAM- to store data base data on disk Format of records in a data base data set need not match the layouts of the segments that make up the data base The way the program sees the data base is different from the way the access method sees it.
Physical structure of a DL/I data base isnt specified in an application program DL/I uses a set of control blocks(DBDs and PSBs) to define a data bases structure Data Base Descriptor (DBD)
Control Blocks
Describes the complete structure of a data base A unique DBD for each DL/I data base
Program Specification Block (PSB)
Application programs that have similar data base processing requirements can share a PSB
Data Base Administrator (DBA) has to create DL/I control blocks DBDGEN and PSBGEN Control Statements
SOURCE STATEMENT PRINT NOGEN DBD NAME=INDBD,ACCESS=HIDAM DATASET DD1=IN,DEVICE=3380 **/ 3380 DISK STORAGE * SEGM NAME=INVENSEG, PARENT=0,POINTER=TB,BYTES=131 LCHILD NAME=(INPXPNTR,INPXDBD),POINTER=INDX FIELD NAME=(INVENCOD,SEQ),BYTES=3,START=1,TYPE=C FIELD NAME=INVENNAM,BYTES=30,START=4,TYPE=C FIELD NAME=INVENADR,BYTES=30,START=34,TYPE=C FIELD NAME=INVENCIT,BYTES=17,START=64,TYPE=C FIELD NAME=INVENSTA,BYTES=2,START=81,TYPE=C FIELD NAME=INVENZIP,BYTES=9,START=83,TYPE=C FIELD NAME=INVENTEL,BYTES=10,START=92,TYPE=C FIELD NAME=INVENCON,BYTES=30,START=102,TYPE=C * SEGM NAME=INITMSEG,PARENT=INVENSEG,BYTES=48 FIELD NAME=(INITMNUM,SEQ),BYTES=5,START=1,TYPE=C FIELD NAME=INITMDES,BYTES=35,START=6,TYPE=C FIELD NAME=INITMPRC,BYTES=4,START=41,TYPE=P FIELD NAME=INITMCST,BYTES=4,START=45,TYPE=P * SEGM NAME=INLOCSEG, PARENT=INITMSEG,BYTES=21 FIELD NAME=(INLOCLOC,SEQ),BYTES=3,START=1,TYPE=C FIELD NAME=INLOCONH,BYTES=4,START=4,TYPE=P FIELD NAME=INLOCROP,BYTES=4,START=8,TYPE=P FIELD NAME=INLOCONO,BYTES=4,START=12,TYPE=P FIELD NAME=INLOCDAT,BYTES=6,START=16,TYPE=C * DBDGEN **/************************************************************************** **/ RECOMMENDED VSAM DEFINE CLUSTER PARAMETERS **/************************************************************************** **/* *NOTE2 **/* DEFINE CLUSTER (NAME(IN) NONINDEXED **/* RECORDSIZE (2041,2041) **/* COUNTERINTERVALSIZE (2048)) **/* *NOTE2 - SHOULD SPECIFY DSNNAME FOR DD IN **/************************************************************************** **/***********SEQUENCE FIELD************* **/***********SEQUENCE FIELD************* FINISH END Fig 2.3 Assembler source listing for the Inventory data base DBDGEN
First macro DBD identifies the data base and specifies the DL/I access method Second macro DATASET- identifies the file that would contain the data base Symbolic name (IN) identifies the data set in the JCL at execution time Segment types are defined using the SEGM macro Segment hierarchical relationships are specified by the PARENT parameter on a SEGM macro
PARENT= 0 or absence of PARENT parameter specifies root segment
POINTER parameter and LCHILD macro are needed for HIDAM Databases Only search fields need be specified in the DB
STMT SOURCE STATEMENT 1 PRINT NOGEN 2 PCB TYPE=DB,DBDNAME=INDBD,PROCOPT=LS 3 SENSEG NAME=INVENSEG 4 SENSEG NAME=INITMSEG,PARENT=INVENSEG 5 SENSEG NAME=INLOCSEG,PARENT=INITMSEG 6 PSBGEN PSBNAME=INLOAD,LANG=COBOL 87 END
SAMPLE PSBGEN
Fig 2.5 Assembler source listing for the Inventory data base load programs PSBGEN
PCB (Program Communication Block) refers to one data base. One PCB macro for each database accessed Segment Level Sensitivity
A programs access to parts of the data base identified at the segment level Within sensitive segments, the program has access to all fields
PSBGEN (contd.)
DBDNAME parameter on the PCB macro specifies the name of the DBD KEYLEN parameter specifies the length of the longest concatenated key the program can process in the data base PROCOPT parameter specifies the programs processing options For each PCB macro, subordinate SENSEG macros identify the sensitive segments in the data base Names specified in the SENSEG macros must be segment names from the DBDGEN for the data base named in the DBDNAME parameter of the PCB macro PSBGEN macro
Indicates that there are no more statements in the PSBGEN job PSBNAME parameter specifies the name to be given to the output PSB module LANG parameter specifies the language in which the related application program will be written.
The PROCOPT given for a Sensitive segment would override the one given for the DB
Example : PCB TYPE=DB,NAME=LDB42F,PROCOPT=G, KEYLEN=200 SENSEG NAME=SEGL4201, PARENT=0,PROCOPT=A WARNING : Indiscriminate use of PROCOPTS can lead to inexplicable results !
//JOBNAME JOB (ACCT),'PGMR NAME', // CLASS=J, // MSGCLASS=Z, // NOTIFY=&SYSUID //JOBLIB DD DSN=YOUR.PROGRAM.LOAD.LIBRARY, // DISP=SHR // DD DSN=YOUR.SYSTEM.RESLIB.LIBRARY, // DISP=SHR //PROC EXEC PROCNAME, SYMBOLIC PARAMETERS //********************************************************* //PROCNAME PROC //******************************************************** //* THIS PROC LOADS AN IMS VSAM DATABASE //* A PROGRAM 'LOAD' IS USED FOR THIS PURPOSE //* THE PSB USED FOR LOADING IS LOADPSB //******************************************************** //LOAD EXEC PGM=DFSRRC00, // PARM='DLI,LOAD,LOADPSB'
Application program is invoked under the control of the batch initialization module DLITCBL => DL/I to COBOL is the entry point to the program DL/I supplies the address of each PCB defined in the programs PSB PCBs must be defined in the Linkage Section Linkage Section definition of a PCB is called a PCB Mask Addressability to PCBs established by listing the PCB Masks on the ENTRY statement
PCB masks should be listed on the ENTRY statement in the same sequence as they appear in your programs PSBGEN GO BACK Statement
When a program ends, it passes control back to the DL/I DL/I reallocates resources and closes the data base data sets
CBLTDLI => COBOL to DL/I, is an interface module that is link edited with your programs object module PLITDLI, ASMTDLI are other options
Update functions
Second parameter on the DL/I call The name of the PCB mask defined in the programs Linkage Section ENTRY statement establishes a correspondence between PCB masks in the Linkage Section and the PCBs within the programs PSB After each DL/I call, DL/I stores a status code in the PCB mask, which the programmer can use to determine whether the call succeeded or failed
Segment I/O Area
Optional parameter on the DL/I call Identifies the segment occurrence you wish to access Multiple SSAs on a single DL/I call Two kinds of SSAs unqualified and qualified An unqualified SSA
Supplies the name of the next segment type that you want to operate on If you issue a GN call with an unqualified SSA, DL/I will return the next occurrence of the segment type you specify
A qualified SSA
Combines a segment name with additional information that specifies the
01 INVENTORY-PCB-MASK. 05 IPCB-DBD-NAME 05 IPCB-SEGMENT-LEVEL 05 IPCB-STATUS-CODE 05 IPCB-PROC-OPTIONS 05 FILLER 05 IPCB-SEGMENT-NAME 05 IPCB-KEY-LENGTH 05 IPCB-NUMB-SENS-SEGS 05 IPCB-KEY
Fig 3.4 PCB mask for an Inventory data base
Specifies the current segment level in the data base After a successful call, DL/I stores the level of the segment just processed in this field
Status code
Contains the DL/I status code When DL/I successfully completes the processing you request in a call, it indicates that to your program by moving spaces to the status code field
The field DL/I uses to report the length of the concatenated key of the lowest level segment processed during the previous call Used with the key feedback area
Number of sensitive segments
Contains the number of SENSEG macros subordinate to the PCB macro for this data base
Key feedback area
Varies in length from one PCB to another As long as the longest possible concatenated key that can be used with the programs view of the
Types of SSAs
SSA identifies the segment occurrence you want to access It can be either
Qualified Unqualified
An unqualified SSA simply names the type of segment you want to use A qualified SSA specifies not only the segment type, but also a specific occurrence of it
Includes a field value DL/I uses to search for the segment you request Any field to which the program is sensitive to can be used in an SSA
Because of the hierarchical structure DL/I uses, you often have to specify several levels of SSAs to access a segment at a low level in a data base
A basic unqualified SSA is 9 bytes long The first eight bytes contain the name of the segment you want to process If the segment name is less than eight characters long, you must pad it on the right with blanks The ninth position of a basic unqualified SSA always contains a blank
A qualified SSA lets you specify a particular segment occurrence based on a condition that a field within the segment must meet The first eight characters of a basic qualified SSA is the eight character segment name The ninth byte is a left parenthesis Immediately following the left parenthesis in positions 10 through 17 is an eight character field name
The qualified SSA relational operators are shown below ( stands for a single blank space)
Equal to Not equal to Greater Than Greater than or Equal to Less Than Less than or Equal to EQ NE GT GE LT LE = <> > >= < <= = > => < =<
After the relational operator, you code a variable field into which you move the
Command Codes
Fig 4.3 Unqualified SSA format with a single command code
To extend DL/I functionality To simplify programs by reducing the number of DL/I calls
F
L N P Q U V
First Occurrence
Last Occurrence Path Call Ignore Set Parentage Enqueue Segment Maintain position at this level Maintain position at this and all superior levels Null command code Fig 4.5 SSA Command Codes
Path Call
A DB call with an SSA that includes the 'D' Command code is a "PATH CALL . Its a facility where in we can retrieve an entire path of the segment Consider a sample GU call
CALL 'CBLTDLI' USING DLI-GU INVEN-PCB-MASK INVEN-STOCK-LOC-SEG VENDOR-SSA ITEM-SSA STOCK-LOC-SSA
Normally, DL/I operates on the lowest level segment that is specified in an SSA(STOCK-LOC-SSA in the above E.g.) In case if we need data from not just from the lowest level but from other levels as well we normally have to give 3 separate GU calls.This will reduce the efficiency of the program Such a call operates on two or more segments rather than just one segment. If a program has to use "Path call" then "P" should be one of the values specified in the PROCOPT parameter of the PCB in the programs PSBGEN. If path call is not explicitly enabled in the PSBGEN job there will be an 'AM' status code.
Multiple Qualifications There are two cases in which you would use multiple qualification
When you want to process a segment based on the contents of two or more fields within it When you want to process a segment based on a range of possible values for a single field
To use multiple qualification, you connect two or more qualification statements (a field name, a relational operator, and a comparison value) within the parentheses of the SSA. To connect them, you use the Boolean operators AND and OR Either of the two symbols shown in the table below may be used for AND or OR The independent AND operator is used for special operations with secondary indexes and will be discussed later
The above SSA, which uses multiple qualifications can be used to retrieve vendor segments whose vendor codes fall within a certain range
The first qualification statement specifies that the vendor code field must be greater than or equal to a particular value; that is the low end of the range The second qualification statement specifies that
The GU Call
Used for random processing Applications of random processing
When a relatively small number of updates are posted to a large data base To establish position in a data base for subsequent sequential retrieval
You know what data you want to retrieve and you want to get to it directly Independent of the position established by the previous calls
DLI-GU INVENTORY-PCB-MASK INVENTORY-STOCK-LOC-SEGMENT VENDOR-SSA ITEM-SSA STOCK-LOCATION-SSA.
The GU Call (contd.) Usually, GU processing is based on sequence (key) fields with unique values
However, for some applications you may find it necessary to either
Access a segment whose sequence field allows nonunique values Access a segment based on a field that is not the segments key field In the above cases, DL/I returns the first segment occurrence with the specified search value
Special considerations for GU calls without a full set of qualified SSAs
1. When you use an unqualified SSA in a GU call, DL/I accesses the first segment occurrence in the data base that meets the criteria you specify 2. If you issue a GU call without any SSAs, DL/I returns the first occurrence of the root segment in the data base
Only two status code values need to be considered spaces and GE Spaces means the call was successful and the requested segment was returned in your programs segment I/O area A GE status code indicates that DL/I couldnt find a segment that met the criteria you specified in the call
The GN Call
CALL CBLTDLI USING DLI-GN INVENTORY-PCB-MASK INVENTORY-STOCK-LOC-SEGMENT STOCK-LOCATION-SSA.
Used for basic sequential processing After any successful data base call, your data base position is immediately before the next segment occurrence in the normal hierarchical sequence Before your program issues any calls, position is before the root segment of the first data base record The GN call moves forward through the data base from the position established by the previous call If a GN call is unqualified (that is, if it does not employ an SSA), it returns the next segment occurrence in the data base regardless of type, in hierarchical sequence If a GN call includes SSAs qualified or unqualified DL/I retrieves only segments that meet requirements of all SSAs you specify If you include an unqualified SSA or omit an SSA altogether for a segment type, DL/I allows any occurrence of that segment type to satisfy the call But when you specify a qualified SSA, DL/I selects only those segment occurrences
Used for sequential processing within parentage Works like the GN call, except it retrieves only segments that are subordinate to the currently established parent To establish parentage, your program MUST issue either a GU call or a GN call, and the call must be successful
Parentage is never automatically established, in spite of the hierarchical structure of the data base
The segment returned by the call becomes the established parent Subsequent GNP calls return only segment occurrences that are dependent on that parent When there are no more segments within the established parentage DL/I returns GE as the status code
Parent
Item 2
When you issue a call with an SSA that includes the F command code, the call processes the first occurrence of the segment named by the SSA, subject to the calls other qualifications Can be used when you are doing sequential processing and you need to back up in the data base, or in other words, the F command code can be used for sequential retrieval using GN and GNP calls Meaningless with GU calls, because GU normally retrieves the first segment occurrence that meets the criteria you specify
01 VENDOR-SSA. 05 FILLER PIC X(11) VALUE INVENSEG*D(. 05 FILLER PIC X(10) VALUE INVENCOD =. 05 VENDOR-SSA-CODE PIC X(3). 05 FILLER PIC X VALUE ). * 01 ITEM-SSA. 05 FILLER PIC X(11) VALUE INITMSEG*D(. 05 FILLER PIC X(10) VALUE INITMNUM =. 05 ITEM-SSA-NUMBER PIC X(5). 05 FILLER PIC X VALUE ). * 01 LOCATION-SSA. 05 FILLER PIC X(11) VALUE INLOCSEG*D(. 05 FILLER PIC X(10) VALUE INLOCLOC =. 05 LOCATION-SSA-CODE PIC X(3). 05 FILLER PIC X VALUE ). * 01 PATH-CALL-I-O-AREA. 05 INVENTORY-VENDOR-SEGMENT PIC X(131). 05 INVENTORY-ITEM-SEGMENT PIC X(48). 05 INVENTORY-STOCK-LOC-SEGMENT PIC X(21). * . . . * CALL CBLTDLI USING DLI-GU INVENTORY-PCB-MASK
Using Command Codes with Retrieval Calls (contd.) The C command code
If you are developing a program that retrieves just lower-level segment occurrences from a data base, you dont have to code separate SSAs for each level in the hierarchical path Instead you can use a single SSA with the C command code Then, rather than coding a field name, relational operator, and search value, you specify the concatenated key for the segment you are interested in An illustration of the use of the C command code is shown below
Using Command Codes with Retrieval Calls (contd.) The P command code
When you issue a GU or GN call, DL/I normally establishes parentage at the lowest level segment that is retrieved However, if you want to override that and cause parentage to be established at a higher-level segment in the hierarchical path, you can use the P command code in its SSA
When you use an unqualified SSA that specifies the U command code in a GN call, DL/I restricts the search for the segment you request to
Using Command Codes with Retrieval Calls (contd.) The Q command code
This command code is used to enqueue, or reserve for exclusive use, a segment or path of segments You only need to use the Q command code in an interactive environment where there is a chance that another program might make a change to a segment between the time you first access it and the time you are finished with it
Multiple Processing
Multiple processing is a general term that means a program can have more than one position in a single physical data base at the same time DL/I lets the programmer implement multiple processing in two ways
The DBA can define multiple PCBs for a single data base Then, the program has two (or more) views of the data base As with PCBs for different data bases, each has its own mask in the Linkage Section and is specified
Multiple positioning
Lets a program maintain more than one position within a data base using a single PCB To do that, DL/I maintains a distinct position for each A1 hierarchical path Data the program processes base Record 1 Most of the time, multiple positioning is used to C13 C12 A2 access segments of two or more types sequentially at B13 C11 B12 Data base the same time B11 Record 2
C22
B22 B21 Fig 5.2 Two data base records to illustrate multiple positioning C21
When you use multiple positioning, DL/I maintains its separate positions based on segment type As a result you include an unqualified SSA in the call that names the segment type whose position you want to use
Here UNQUALIFIED-SSA specifies the segment name Because the SSA is unqualified, DL/I tries to satisfy the call based on the current position in the data base As a result, you need to be careful about position when you issue an ISRT call that specifies only a single unqualified SSA
If SSAs for vendor and item are initialized with the proper key values, DL/I inserts the new segment occurrence in the correct position in the data base When you issue a fully qualified ISRT call like this, DL/I returns a status code of GE if any segment occurrence you specify in an SSA isnt present in the data base As a result, you can issue an ISRT call with qualified SSAs instead of first issuing GU calls to find out if higher-level segments in the path are present By issuing one call instead of two (or more), you can save system resources
If the new segment has a unique sequence field, as most segment types do, it is added in its proper sequential position However, some lower-level segment types in some data bases have non-unique sequence fields or dont have sequence fields at all When thats the case, where the segment occurrence is added depends on the rules the DBA specifies for the data base For a segment without a sequence field, the insert
GE When you use multiple SSAs and DL/I cannot satisfy the call with the specified path I I When you try to add a segment occurrence that is already present in the data base For load processing you might get status codes LB, LC, LD or LE.
In most cases they indicate that you are not inserting segments in exact hierarchical sequence That means there is an error in your program or the files from which you are loading the data base contain incorrect data
1.GHU (Get hold unique) 2.GHN (Get hold next), and, 3.GHNP (Get hold next within parent)
These calls parallel the three retrieval calls earlier discussed Before you can replace or delete a segment, you must declare your intent to do so, by retrieving the segment with one of these three calls Then you must issue the replace or delete call before you do another DL/I processing in your program
1. You cant change the length of the segment 2. You cant change the value of the sequence field (if the segment has one)
Never code a qualified SSA on an REPL call: if you do, the call will fail An example of a typical replace operation is shown below
CALL CBLTDLI USING DLI-GHU INVENTORY-PCB-MASK INVENTORY-STOCK-LOC-SEGMENT VENDOR-SSA ITEM-SSA LOCATION-SSA. ADD TRANS-RECEIPT-QTY TO ISLS-QUANTITY-ON-HAND. SUBTRACT TRANS-RECEIPT-QTY FROM ISLS-QUANTITY-ON-ORDER. CALL CBLTDLI USING DLI-REPL
If you try to use a qualified SSA on an REPL call, you will get an AJ status code If your program issues a replace call without an immediately preceding get hold call, DL/I returns a DJ status code If your program makes a change to the segments key field before issuing the REPL call, DL/I returns a DA status code
Notice that the DLET call does not include any SSAs There is one important point you must keep in mind whenever you use the DLET call when you delete a segment, you automatically delete all segment occurrences subordinate to it The status codes you might get after a DLET call are the same as those you can get
Field STATUS-CODE X(02) in the PCB-MASK definition Acceptable and unacceptable status codes GE record occurrence not found GB End of DB reached
Status codes relate to the type of IMS call GHN, GHNP, GHU, GU AB, AK, GE, GB
IMS Abends
U0456 -- PSB stopped U0456 -- IMS Compile option DLITCBL not set to Y U0458 -- DB Stopped U0844 -- DB being updated is full S013 -- Error opening the DB
A few tips on resolving IMS abends: Confirm that the Abend is caused by IMS check the job log for IMS return code
Check the JCL if modified from another JCL, verify that changes are correct Check the SYSOUT dump for IMS diagnostic messages Use MVS/QW to get further information on the abend
PIC X(19) VALUE 'HOSPITAL(HOSPNAME ='. PIC X(20). PIC X VALUE ')'. PIC X(19) VALUE 'WARD PIC X(04). PIC X VALUE ')'. PIC PIC PIC PIC PIC PIC PIC PIC X(19) VALUE 'PATIENT X(20). X VALUE ')'. X(9) VALUE 'HOSPITAL X(9) VALUE 'WARD X(9) VALUE 'PATIENT X(4) VALUE 'ISRT'. X(4) VALUE 'GHU '. (WARDNO ='.
(PATNAME ='.
PIC X(20).
X(8). XX. XX. X(4). S9(5) COMP. X(8). S9(5) COMP. S9(5) COMP. X(26).
PROCEDURE DIVISION. ENTRY 'DLITCBL' USING PCB-MASK. PERFORM INSERT-HOSP-PARA THRU INSERT-HOSP-EXIT. PERFORM INSERT-WARD-01-PARA THRU INSERT-WARD-01-EXIT. PERFORM INSERT-PATIENTS-PARA THRU INSERT-PATIENTS-EXIT. GOBACK. INSERT-HOSP-PARA. MOVE 'MACNEAL TO HOSP-NAME. MOVE 'ABC DDDD' TO HOSP-ADDRESS. MOVE '12345' TO HOSP-PHONE. CALL 'CBLTDLI' USING WS-ISRT PCB-MASK HOSP-I-O-AREA UNQUAL-HOSPITAL-SSA.
TO TO TO TO TO TO TO
Ship-to
Buyer
Receivable
Payment
Fig 7.1 The customer data base
Adjustment
Line Item
COMP-3.
COMP-3.
COMP-3. COMP-3.
Fig 7.2 Segment Layouts for the Customer Data Base (Part 2 of 2)
Secondary Indexes
Customer Ship-to
Index Target Segment
Secondary Index Data Base Invoice number index data base Prefix Data Invoice Rec. Seg. Index No. Addr. Pointer Segment
Buyer
Receivable
Payment
Adjustment
Line Item
Indexed Data Base
Fig 7.3 Secondary Indexing Example in which the Index Source Segment and the Index Target Segment are the same
Secondary Indexes (contd.) DL/I maintains the alternate sequence by storing pointers to segments of the indexed
data base in a separate index data base A secondary index data base has just one segment type, called the index pointer segment The index pointer segment contains two main elements a prefix element and a data element The data element contains the key value from the segment in the indexed data base over which the index is built, called the index source segment The prefix part of the index pointer segment contains a pointer to the index target segment the segment that is accessible via the secondary index The index source and target segments need not be the same After a secondary index has been set up, DL/I maintains it automatically as changes are made to the indexed data base though the index is transparent to application programs that use it
So, even if a program that is not sensitive to a secondary index updates a data base record in a way that would affect the index, DL/I automatically
In practice, the number of secondary indexes for a given data base is kept low because each imposes additional processing overhead on DL/I
Secondary Keys
The field in the index source segment over which the secondary index is built is called the secondary key The secondary key need not be the segments sequence field any field can be used as a secondary key Though usually, a single field within the index source segment is designated as the secondary key for a secondary index, the DBA can combine as many as five fields in the source segment to form the complete secondary key
Secondary Data Structures A secondary index changes the apparent hierarchical structure of the data base
The index target segment is presented to your program as if it were a root segment, even if it isnt actually the root segment As a result, the hierarchical sequence of the segments in the path from the index target segment to the root segment is inverted: those segments appear to be subordinate to the index target segment, even though they are actually superior to it The resulting rearrangement of the data base structure is called a secondary data structure
Receivable
Ship-to
Payment
Adjustment
Line Item
Customer
Buyer
They just alter the way DL/I presents those segments to application programs
When you code an application program that processes a data base via a secondary index, you must consider how the secondary data structure affects your programs logic
DBDGEN Requirements for Because a secondary index relationship involves two data bases, two DBDGENs are Secondary Indexes required one for the indexed data base and the other for the secondary index data
base
Fig 7.5 Partial DBDGEN output for the customer data base showing the code to implement the secondary index
Fig 7.6 DBDGEN output for the Secondary Index Data Base
In the DBDGEN for the indexed data base, an LCHILD macro relates an index target segment to its associated secondary index data base In the DBDGEN for the secondary index data base, an LCHILD macro relates the index pointer segment to the index target segment
This key field does not become a part of the segment Instead, its value is derived from up to five fields defined within the segment with FIELD macros
The SRCH parameter defines the field(s) that constitute the secondary index
PSBGEN Requirements for Just because a secondary index exists for a data base doesnt mean DL/I will Secondary Indexing automatically use it when one of your programs issues calls for that data base
You need to be sure that the PSBGEN for the program specifies the proper processing sequence for the data base on the PROCSEQ parameter of the PSB macro If it doesnt, processing is done using the normal hierarchical sequence for the data base For the PROCSEQ parameter, the DBA codes the DBD name for the secondary index data base that will be used
Customer
Ship-to
Buyer
Receivable
Index Source Segment
Payment
Adjustment
Line Item
Indexed Data Base
Fig 7.8 Secondary Indexing Example in which the Index Source Segment and the Index Target Segment are different
Indexing a Segment based on a Dependent Segment (contd.) The Index Source Segment and the Index Target Segment need not be the same
Some applications require that a particular segment be indexed by a value that is derived from a dependent segment
In such a case, the Index Target Segment and the Index Source Segment are different For example, in Fig 7.8, you can retrieve customers based on items they have purchased In other words, the SSA for a get call would specify an item number, but the call would retrieve a customer segment
The only restriction you need to be aware of here is that the Index Source Segment must be a dependent of the Index Target Segment
Sparse Sequencing When the DBA implements a secondary index data base with sparse sequencing (also
called sparse indexing), it is possible to omit some index source segments from the index Sparse sequencing can improve performance when some occurrences of the index source segment must be indexed but others need not be DL/I uses a suppression value, a suppression routine, or both to determine whether a segment should be indexed (either when inserting a new segment or processing an existing one) If the value of the sequence field(s) in the index source segment matches a suppression value specified by the DBA, no index relationship is established (for an insert) or expected (for any other call) The DBA can also specify a suppression routine that DL/I invokes to determine the index status for the segment The suppression routine is a user-written program that evaluates the segment and determines whether or not it should be indexed Note:
When sparse indexing is used, its functions are handled by DL/I You dont need to make special provisions for it in
Duplicate data fields impose extra DL/I overhead and require extra DASD storage It is the DBAs responsibility to decide whether the advantages of using duplicate data fields outweigh the extra DL/I overhead and DASD storage requirements mentioned above
An Introduction to Logical Data Inter related databases Bases A logical child segment has 2 parent segments
One Inter related databases. physical parent and one logical parent
DB2
SEG-1
DB1
PP
Physical Parent
LP
SEG-a SEG-b RLC
Real Logical Child
Logical Parent
C2
VLC
Virtual Logical Child
Unidirectional.
******DBD2******* . . . 6 SEGM NAME=LP, PARENT=SEG-1, BYTES=48 7 LCHILD NAME= (RLC,DBD1), POINTER=PTR, PAIR=VLC 8 FIELD NAME=******************************** 9 FIELD NAME=******************************** 10 FIELD NAME=********************************
Data base changes for a time period is accumulated A copy of the data base is created The changes are applied to this data base copy DL/I uses change-data stored in DL/I logs for
Introduction to Checkpointing
Synonyms: synchronization point, sync point, commit point and point of integrity Program execution point at which the DB changes are complete and accurate DB changes made before the most recent checkpoint are not reversed by recovery Normally the start of the pgm is considered as a default checkpoint In case of a number of DB updates, explicit checkpoints can be specified Explicit checkpoints can be established using checkpoint call(CHKP) inside the program CHKP creates a checkpoint record on DL/I log which prevents recovery before that point
Types of Checkpointing
Types of checkpointing
Simple form of checkpointing. Issues checkpoint calls that the DL/I recovery utilities use during recovery processing
Symbolic checkpointing
More advanced type of checkpointing Used in combination with extended restart Programs resume from the point following the
In the I/O area pointed to by the XRST call Specifying ID in the CKPTID= field of EXEC statement in the program's JCL
Traditionally, batch cycle starts at 7 pm and ends at 7 am Image Copy jobs are usually run before and after a batch cycle If abend occurs, revert to the DB generated by image copy job and rerun Commonly used image copy utility is BMC Softwares ICPUMAIN Database and Image copy DD names specified in the ICPSYSIN card
Hierarchic Sequential: In this the segments that make up the database record are related to one another by their physical locations. Hierarchic Direct : In this the segment occurrences include prefixes that contain direct pointers to related segments.
HSAM ( Hierarchic Sequential Access Method) : The program in HSAM database works through it sequentially from beginning to end.The application programs cannot replace or delete segments without copying the entire database. HISAM (Hierarchic Indexed Sequential Access Method): In HISAM the data is stored with hierarchic sequential organization. An index is also maintained to allow random access to any database record. SHSAM( Simple Hierarchical Sequential Access
HDAM stores root segment occurrences based on a randomizing routine. Occurrences of dependent segments are related to root and one another by a system of pointers the HD Organization is based upon. HDAM databases are not appropriate for sequential processing.
HIDAM (Hierarchic Indexed Direct Access Method) :
Segment data in HIDAM is stored in the same way like that in HDAM.
GSAM lets application files to be treat OS sequential files as databases. Data is processed on a record to record to basis but through DL/I calls. Processing of database is sequential , ISRT add data only at the end of database & REPL and DLET calls are not supported. They are typically used during conversion from a system that uses standard files to one that uses data bases.
DEBD is stored in disk and has a hierarchical structure They are organized in typical DL/I fashion, as direct dependent segment types. DEBDs use a complicated storage scheme that involves separating the data base into as many as 240 areas and this allows very large data bases.
m=maximum length of the segment + 2 bytes n=minimum length of the segment + 2 bytes The extra two bytes is used to store the length field of the occurrence of the variable length segment In Application Program :
The length field has to be included in the I-O Area for the segment. Length PIC S 9(4)
If the occurrence of the segment type grows in length then Variable length segment will drop performance When segment type occurrences grow in size then it split's into 2 parts which are not stored in the same physical record, so we require two I/O operations to fetch the segment therefore the
SEGM and FIELD statements The use of logical or index relationships between segments
IMS adds 2 bytes to the record length value specified in the DBD in order to
Thank You