Ims-Db: Information Management System DB Concepts & Programming
Ims-Db: Information Management System DB Concepts & Programming
Ims-Db: Information Management System DB Concepts & Programming
IMS DBs
DB1 DB2 DB3
DBD : Database Description, describes physical Database
DBDGEN : DBDGEN Utility, Describes the physical structure of
the Database and creates DBD
DBD NAME=KANBAY,ACCESS=(HIDAM,VSAM)
DSG1 DATASET DD1=DDSAT,DEVICE=3380,SIZE=4096,FRSPC=0,15)
SEGM NAME=KBU,PARENT=0,BYTES=40
FIELD NAME=(KBUCODE,SEQ,U),BYTES=3,START=1,TYPE=P
FIELD NAME=KBUNAME,BYTES=5,START=4,TYPE=C
FIELD NAME=KBULOC,BYTES=12,START=9,TYPE=C
FIELD NAME=KBUHEAD,BYTES=20,START=21,TYPE=C
SEGM NAME=CLIENT,PARENT=KBU,BYTES=45
FIELD NAME=(CLTID,SEQ,U),BYTES=4,START=1,TYPE=P
FIELD NAME=CLTNAME,BYTES=10,START=5,TYPE=C
FIELD NAME=CLTLOC,BYTES=11,START=15,TYPE=C
FIELD NAME=CLTHEAD,BYTES=20,START=26,TYPE=C
SEGM NAME=PROJECT,PARENT=CLIENT,BYTES=35
FIELD NAME=(PRJID,SEQ,U),BYTES=4,START=1,TYPE=P
FIELD NAME=PRJNAME,BYTES=5,START=5,TYPE=C
FIELD NAME=PRJTMSIZE,BYTES=4,START=10,TYPE=C
FIELD NAME=PRJHEAD,BYTES=22,START=14,TYPE=C
SEGM NAME=EMPLY,PARENT=KBU,BYTES=40
FIELD NAME=(EMPID,SEQ,U),BYTES=5,START=1,TYPE=P
FIELD NAME=EMPNAME,BYTES=10,START=6,TYPE=C
FIELD NAME=EMPPROJ,BYTES=5,START=16,TYPE=C
FIELD NAME=EMPADDR,BYTES=20,START=21,TYPE=C
SEGM NAME=SALARY,PARENT=EMPLY,BYTES=35
FIELD NAME=(SALEMPID,SEQ,U),BYTES=5,START=1,TYPE=P
FIELD NAME=SALBASIC,BYTES=10,START=6,TYPE=C
FIELD NAME=SALHRA,BYTES=5,START=16,TYPE=C
FIELD NAME=SALDA,BYTES=5,START=21,TYPE=C
DBDGEN
FINISH
END
PSB
Program Specification Block,describes Logical structure of the Database that a
program will use.It contains one or more PCB’s (Program Communication Block).
PCB describes one Database.
PSBGEN
PSBGEN Produces a load module stored in the PSBLIB library and creates PSB
Major Macros Used
PCB : Describes type (DB or DC), name of the DBD, Key length(length of
the longest concatenated key the program can process) and
processing Option (Defines how the segment may be accessed)
PCB TYPE=DB,DBDNAME=KANBAY,KEYLEN=20,PROCOPT=LS
SENSEG : Define the name of the segments in the Database your program
needs access to
SENSEG NAME=CLIENT,PARENT=KBU
SENFLD : Subordinate to the SENSEG macro, only fields that are defined by
the SENFLD macro can be accessed from the I/O Area.
SENFLD NAME=PROJECT,PARENT=CLIENT
PSBGEN PSBNAME=KANPSB,LANG=COBOL
END
SAMPLE PSB FOR KANBAY INFO DB PROJECT REFERENCE PROGRAM
PCB TYPE=DB,DBDNAME=KANBAY,KEYLEN=10,PROCOPT=LS
SENSEG NAME=KBU,PARENT=0
SENSEG NAME=CLIENT,PARENT=KBU
SENSEG NAME=PROJECT,PARENT=CLIENT
PSBGEN PSBNAME=KANPSB,LANG=COBOL
END
PCB TYPE=DB,DBDNAME=KANBAY,KEYLEN=10,PROCOPT=LS
SENSEG NAME=KBU,PARENT=0
SENSEG NAME=CLIENT,PARENT=KBU
SENSEG NAME=PROJECT,PARENT=CLIENT
SENSEG NAME=EMPLY,PARENT=KBU
SENSEG NAME=SALARY,PARENT=EMPLY
PSBGEN PSBNAME=KANPSB,LANG=COBOL
END
DL/I INTERFACE
This DL/I tells entry of the program for Batch program & MPP program
This call is the name of the interface module that link edited with your
program’s object module.
CALL PARAMETERS
Parameter Function
DL/I -Function A four byte code that tells DL/I what kind of call to make
PCB-mask Arguments tells DL/I which PCB to use for the call
IO-Area Tells DL/I where to put the segment
SSA Gives DL/I additional criteria to use in finding a particular
Segment, Can be upto 15 SSA’s
DL/I FUNCTIONS
GU - Get Unique
GN - Get Next
GNP - Get Next within Parent
GHU - Get Hold Unique
GHN - Get Hold Next
GHNP - Get Hold Next within Parent
ISRT - To Insert
REPL - To replace
DLET - To Delete
CHKP - To take a Checkpoint at a particular point
XRST - To Restart from Particular point previous Checkpoint
INIT - To Initialize
SYNC - To commit
PCB MASK
VARIABLE DESCRIPTION
01 KANBAY-PCB-MASK.
03 KAN-DBD-NAME PIC X(8). Name of the Database being processed
03 KAN-SEG-LEVEL PIC XX. Specifies current segment level in the DB
03 KAN-STATUS-CODE PIC XX. Contains data yr program will evaluate after call
03 KAN-PROC-OPT PIC X(4). Type of processing the program authorized to do
03 KAN-SEG-NAME PIC X(8). Stores name of the segment just proceeded
03 KAN-KEY-LENGTH PIC S9(5). Length of the concatenated key
03 KAN-NUM-SENSEGS PIC S9(5). No of SENSEG macros subordinate to the PCB
03 KAN-KEY-VALUE PIC X(20). Key value retrieved
I-O AREA LAYOUT FOR SEGMENTS
UNQUALIFIED QUALIFIED
• Search for a Specific Segment type Searches for a specific occurrence of a
specific segment type
• Access the database Sequentially Access the database Randomly
• Identify by segment name and space Identify by segment name and Seg-key
• Example
01 UNKBU-SSA. 01 QUALKBU-SSA.
03 KBU-UNSSA-NM PIC X(8) Value ‘KBU ‘. 03 SEG-NAME PIC X(8) VALUE ‘KBU ‘.
03 FILLER PIC X Value Space. 03 COM-CODE PIC X(2) VALUE ‘*-’.
03 BEGIN-QUAL PIC X VALUE ‘(‘.
03 KEY-NAME PIC X(8) VALUE ‘KBUKEY’.
03 REL-OPR PIC X(2) VALUE ‘= ‘.
03 KEY-VALUE PIC X(20).
03 END-QUAL PIC X VALUE ‘)’.
COMMAND CODES
D Retrieve Path
F Access First Segment occurrence
L Access Last Segment occurrence
U Maintain current position at this level
V Maintain current position at this level and higher levels
Q Enqueue Segment
N Do Not replace this Segment
C Use a Concatenated Key
P Establish Percentage at this level
- Null command code / ignore
Data Sensitivity
•DBA
At a PSB level for SEGMENTS PROCOPT
PCB TYPE=DB,DBDNAME-KANBAY,,KEYLEN=11,PROCOPT
SENSEG NAME =KBU,PARENT=0
SENSEG NAME =CLIENT,PARENT=KBU
•Programmer
At PROGRAM Level
- Qualified SSA call with Command code N (No Replacement)
Checkpointing & Restart
• A point in the program where the database changes the program made are
Considered complete and accurate -written to a DL/I log
• Used for Recovery Process
• Are of two types - Basic Checkpointing and Symbolic Checkpointing
• Basic Checkpointing
CALL ‘CBLTDLI’ USING DLI-CHKP,
I-O-PCB-MASK,
CHECKPOINT-ID.
• Symbolic Checkpointing
Stores program data along with checkpoint records and retrieves that data
when program restarts after failure.
For extended Restart , an XRST call to be issued with the same fields as in
CHKP call. It allows DL/I to retrieve the value in checkpoint record and
restores the specified fields.
Explosive Mix - IMS DB with CICS
• Scheduling Call
User Task
Program Communication
Block
(PCB)
A DL/I task must establish addressability to UIB and one or more PCB
IMS & CICS Continued
PCB1
PCB2
Secondary Indexing
EMP..Seg Employee ID
Addr
Index Target
KBU Index Pointer Segment
Segment
CLIENTS EMPLOYEE
KBU..Seg Employee ID
Addr
Index Target
KBU Index Pointer Segment
Segment
CLIENTS EMPLOYEE
• Secondary index data base has only one segment type - the Index pointer segment
which in turn contains a prefix element and a data element
• Two DBDGENS are required as a secondary database involves two database: one
for indexed database , the other for the secondary index database
Secondary Indexing Continued
DBD NAME=KANBAY,ACCESS=(HIDAM,VSAM)
DSG1 DATASET DD1=DDSAT,DEVICE=3380,SIZE=4096,FRSPC=0,15)
SEGM NAME=KBU,PARENT=0,BYTES=40
FIELD NAME=(KBUCD,SEQ,U),BYTES=2,START=1,TYPE=P
……
SEGM NAME=EMPLY,PARENT=KBU,BYTES=80
LCHILD NAME= (KANPNTR,KANDBD),POINTER=INDX
FIELD NAME=(EMPID,SEQ,U),BYTES=5,START=1,TYPE=P
XDFLD NAME=KANINDX,SRCH=EMPID
FIELD NAME=EMPNAME,BYTES=25,START=6,TYPE=C
FIELD NAME=EMPPROJ,BYTES=15,START=31,TYPE=C
FIELD NAME=EMPADDR,BYTES=35,START=46,TYPE=C
…….
Secondary Indexing Continued
DBD NAME=KANIDBD,ACCESS=(INDEX)
DSG1 DATASET DD1=DDKAY,DEVICE=3380,SIZE=4096,FRSPC=0,15)
SEGM NAME=KANPNTR,PARENT=0,BYTES=6
LCHILD NAME= (EMPID,KANBAY), INDX=KANINDX
FIELD NAME=(KANEMPID,SEQ,U),BYTES=6,START=1,TYPE=C
DBDGEN
FINISH
END
• DL/I
It can be used as Interface between MPP and Database OR BMP and Database
For batch DL/I job it can access database directly
PSB of DL/I job can be used by another jobs simultaneously
It can run on Individual partitions.
Using HFCTDLI