Вы находитесь на странице: 1из 36

IMS-DB

InIormation Management System


DB Concepts & Programming
Files Vs Databases
Networked,Hierarchical & Relational structure
Access types - HSAM, HISAM,HDAM,HIDAM,VSAM
IMS DB - an Hierarchical Structure
Database DeIinitions - DBD
Program SpeciIication Block ,Program Control Block
DL/I Calls - Data Retrieval and Manipulation
DL/I Functions
QualiIied/ UnqualiIied Calls, SSAs, Command Codes
DL/I Status codes
Basic Topics
IMS DB Topics
IMS DB - HierarchicaI Structure
Database Definitions - DBD
Program Specification BIock ,Program ControI BIock
DL/I CaIIs - Data RetrievaI and ManipuIation
DL/I Functions
QuaIified/ UnquaIified CaIIs, SSAs, Command Codes
DL/I Status codes
Checkpoint & Restart
Difference between MPP, BMP, DLI
Advanced Topics
Data Sensitivity - Segment Level & Field level
Checkpoint & Restart
IMS DB in CICS Environment
Secondary Indexing
DiIIerence between MPP, BMP, DLI
File Vs Databases
Data more redundant Redundancy avoided
Duplicate data Minimise Duplicates
Data insecure Security provided
No control over data Field level sensitivity
Threat to Integrity Consistency oI data
Lack oI inbuilt Data Logging,
recovery Ieatures Commits & Rollbacks
Lack oI data Locks Automatic locks
Database Structures
Network Structures (e.g IDMS)
Many to Many relationships
Complex structure using Pointers
Best Ior Keeping storage
erarchcal Structures (e.g IMS DB)
ne to Many Relationships
Inverted Tree like Structure
Best Ior storing parent and child type entities
#elatonal Structures (e.g DB2)
ne to Many, Many to ne
Best Ior ease oI data retrieval
Access Types
HSAM/SHSAM (Simple /Hierarchic sequential Access Method)
The segments that make up the database record are related to one another by
their physical locations (SHSAM has only root occurrences)
HISAM/SHISAM (Simple / Hierarchic Indexed Sequential Access Method)
The data is stored with hierarchic sequential organization along with an index
Ior random processing (SHISAM has only index oI root occurrences)
HDAM (Hierarchic Direct Access Method)
The segment occurrences include preIixes that contain the direct address
pointers to related segment - stores root segment occurrences
HIDAM(Hierarchic Indexed Direct Access Method)
Similar to HDAM but stores an index oI the root segment occurrences
MS DB Hierarchical Structure
SRCS
nformation
Database
Stratergic Business
Units info
Project nfo
Client nfo Employee data
Employee Salary
Details
Projects
Clients
Salary
Employ
SRCSunits
Basic IMS Terminologies
SRCS Units
2
1
3
Clients Employ
Projects Salary
Segment
ccurrence
Root Segment
Parent Segment
Child Segment
Segment Level
Path
Database Record
Twins
Sequential Processing
Random Processing
SRCS
InIormation
Database
Client InIo
Project InIo
DeIinitions
Segment
- Unit oI InIormation handled in IMS
- Unit oI data transIerred Irom DL/I in an I operation
- Consists oI Iields, key Iields & Search Iields
ccurrence
- SpeciIic segment oI a particular type oI segment
- Contains actual user data
Root Segment
- Top oI the hierarchy
- All other segments are derived Irom the root
Parent Segment
- Segment that has dependent segments
DeIinitions (contd)
Child Segment
- A dependent segment
Segment Level
- Depth oI an IMS structure
- Root is at Level 0, max 15 levels, max 255 segments
Path
- Series oI segments Irom Root to the child
Database record
- Each occurrence oI the Segment Plus all
occurrence oI the subordinate segments
Twins
- Segment occurrences oI same type with same parent
segment occurrence
IMS Control Blocks
IMS
PGM1
IMS
PGM2
DL/I
CNTRL
UNIT
DBD1 DBD2 DBD3
PCB Ior DB1
PCB Ior DB2
PCB Ior DB3
PSB
DBDs
IMS DBs
DB1 DB2 DB3
DBD : Names the database and identiIies the access method
DBD Name SRCS, ACCESS(HIDAM,VSAM)
DATASET : SpeciIies DD Name used in the JCL and other parameters
DATASET DD1DDSAT,DEVICE3380,SIZE(4096),FRSPC(0,15)
SEGM : Names the segment. IdentiIies the parent and establishes the length
SEGM Name SRU,PARENT0,BYTES40
LCHILD : Names the logical segment used in secondary Indexing and Logical
database
LCHILD NAME(SRUNAME,SRCS1),PTRINDX
FIELD : DeIines Iields. And identiIies search &key Iields by SEQ parameter
FIELD NAME(SRUCDE,SEQ,U)BYTES3,START1,TYPEC
DBDGEN: Indicates the end oI the DBDGEN process
DBDGEN
CMMENT: *` IN 3rd CLUMN Ior writing user comments
DBD : Database Description, describes physical Database
DBDGEN : DBDGEN Utility, Describes the physical structure oI
the Database and creates DBD
Sample DBD Listing Ior SRCS InIo Database
DBD NAMESRCS,ACCESS(HIDAM,VSAM)
DSG1 DATASET DD1DDSAT,DEVICE3380,SIZE4096,FRSPC0,15)
SEGM NAMESRU,PARENT0,BYTES40
FIELD NAME(SRUCDE,SEQ,U),BYTES3,START1,TYPEP
FIELD NAMESRUNAME,BYTES5,START4,TYPEC
FIELD NAMESRULC,BYTES12,START9,TYPEC
FIELD NAMESRUHEAD,BYTES20,START21,TYPEC
SEGM NAMECLIENT,PARENTSRU,BYTES45
FIELD NAME(CLTID,SEQ,U),BYTES4,START1,TYPEP
FIELD NAMECLTNAME,BYTES10,START5,TYPEC
FIELD NAMECLTLC,BYTES11,START15,TYPEC
FIELD NAMECLTHEAD,BYTES20,START26,TYPEC
SEGM NAMEPRJECT,PARENTCLIENT,BYTES35
FIELD NAME(PRJID,SEQ,U),BYTES4,START1,TYPEP
FIELD NAMEPRJNAME,BYTES5,START5,TYPEC
FIELD NAMEPRJTMSIZE,BYTES4,START10,TYPEC
FIELD NAMEPRJHEAD,BYTES22,START14,TYPEC
SEGM NAMEEMPLY,PARENTSRU,BYTES40
FIELD NAME(EMPID,SEQ,U),BYTES5,START1,TYPEP
FIELD NAMEEMPNAME,BYTES10,START6,TYPEC
FIELD NAMEEMPPRJ,BYTES5,START16,TYPEC
FIELD NAMEEMPADDR,BYTES20,START21,TYPEC
SEGM NAMESALARY,PARENTEMPLY,BYTES35
FIELD NAME(SALEMPID,SEQ,U),BYTES5,START1,TYPEP
FIELD NAMESALBASIC,BYTES10,START6,TYPEC
FIELD NAMESALHRA,BYTES5,START16,TYPEC
FIELD NAMESALDA,BYTES5,START21,TYPEC
DBDGEN
FINISH
END
PSB
Program SpeciIication Block,describes Logical structure oI 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 oI the DBD, Key length(length oI
the longest concatenated key the program can process) and
processing ption (DeIines how the segment may be accessed)
PCB TYPEDB,DBDNAMESRCS,KEYLEN20,PRCPTLS
SENSEG : DeIine the name oI the segments in the Database your program
needs access to
SENSEG NAMECLIENT,PARENTSRU
SENFLD : Subordinate to the SENSEG macro, only Iields that are deIined by
the SENFLD macro can be accessed Irom the I/ Area.
SENFLD NAMEPRJECT,PARENTCLIENT
PSBGEN PSBNAMEMYPSB,LANGCBL
END
SAMPLE PSB FR SRCS INF DB PRJECT REFERENCE PRGRAM
PCB TYPEDB,DBDNAMESRCS,KEYLEN10,PRCPTLS
SENSEG NAMESRU,PARENT0
SENSEG NAMECLIENT,PARENTSRU
SENSEG NAMEPRJECT,PARENTCLIENT
PSBGEN PSBNAMEMYPSB,LANGCBL
END
SAMPLE PSB FR SRCS INF DB PRJECT REFERENCE PRGRAM
PCB TYPEDB,DBDNAMESRCS,KEYLEN10,PRCPTLS
SENSEG NAMESRU,PARENT0
SENSEG NAMECLIENT,PARENTSRU
SENSEG NAMEPRJECT,PARENTCLIENT
SENSEG NAMEEMPLY,PARENTSRU
SENSEG NAMESALARY,PARENTEMPLY
PSBGEN PSBNAMEMYPSB,LANGCBL
END
DL/I INTERFACE
DL/I passes control to your program
Uses ENRTY and CALL statement to code DL/I call in the Procedure Division
ENTRY DLITCBL` USING PCB-name1
PCB-name2
This DL/I tells entry oI the program Ior Batch program & MPP program
CALL CBLTDLI` USING DLI-FUNCTIN
PCB-mask
Segment-io-area
|segment search arguments (s)|
This call is the name oI the interIace module that link edited with your
program`s object module.
CALL PARAMETERS
CALL CBLDTLI` USING DLI-FUNCTIN
PCB-mask
Segment-io-area
|segment search argument (s) |
II we use PL/I language then CBLTDLI will be PLITDLI
Parameter Function
DL/I -Function A Iour byte code that tells DL/I what kind oI call to make
PCB-mask Arguments tells DL/I which PCB to use Ior the call
I-Area Tells DL/I where to put the segment
SSA Gives DL/I additional criteria to use in Iinding a particular
Segment, Can be upto 15 SSA`s
DL/I FUNCTINS
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 Irom Particular point previous Checkpoint
INIT - To Initialize
SYNC - To commit
PCB MASK
DeIine in linkage Section and establishes correspondence between linkage Section
PSB-mask and PSB`s with in your program.
SAMPLE PCB-MASK LAYUT
'#IBLE DESC#IPTION
01 SRCS-PCB-MASK.
03 SR-DBD-NAME PIC X(8). Name oI the Database being processed
03 SR-SEG-LEVEL PIC XX. SpeciIies current segment level in the DB
03 SR-STATUS-CDE PIC XX. Contains data yr program will evaluate aIter call
03 SR-PRC-PT PIC X(4). Type oI processing the program authorized to do
03 SR-SEG-NAME PIC X(8). Stores name oI the segment just proceeded
03 SR-KEY-LENGTH PIC S9(5). Length oI the concatenated key
03 SR-NUM-SENSEGS PIC S9(5). No oI SENSEG macros subordinate to the PCB
03 SR-KEY-VALUE PIC X(20). Key value retrieved
I- AREA LAYUT FR SEGMENTS
SRUCDE SRUNAME SRULC SRUHEAD
01 SRU-AREA.
03 SRU-CDE PIC X(3).
03 SRU-NAME PIC X(5).
03 SRU-LC PIC X(12)
03 SRU-HEAD PIC X(20).
CLTID CLTNAME CLTLC CLT-HEAD
01 CLIENT-AREA.
03 CLT-CLTID PIC X(4).
03 CLT-CLTNAME PIC X(10).
03 CLT-CLTLC PIC X(11)
03 CLT-CLTHEAD PIC X(20).
PRJID
PRJNAME TMSIZE PRJADDR
01 PRJ-AREA.
03 PRJ-PRJID PIC X(4).
03 PRJ-PRJNAME PIC X(5).
03 PRJ-TMSIZE PIC X(4)
03 PRJ-HEAD PIC X(20).
EMPID EMPNAME EMPPRJ EMPADR
01 EMP-AREA.
03 EMP-ID PIC X(5).
03 EMP-NAME PIC X(10).
03 EMP-PRJ PIC X(5)
03 EMP-ADR PIC X(20).
01 SAL-AREA.
03 SAL-EMPID PIC X(5).
03 SAL-BASIC PIC X(10).
03 SAL-HRA PIC X(5).
03 SAL-DA PIC X(5).
EMPID BASIC HRA DA
SEGMENT SEARCH ARGUMENT
IdentiIies Segment ccurrence You want to access
You may have to code several SSA`s in a single DL/I CALL
There are two types oI SSA`s UnqualiIied SSA & QualiIied SSA
UNQUALIFIED QUALIFIED
Search Ior a SpeciIic Segment type Searches Ior a speciIic occurrence oI a
speciIic segment type
Access the database Sequentially Access the database Randomly
IdentiIy by segment name and space IdentiIy by segment name and Seg-key
Example
UNS#U-SS. QULKBU-SS.
S#U-UNSS-NM PIC X(8) 'alue S#U . SEG-NME PIC X(8) 'LUE S#U .
FILLE# PIC X 'alue Space. COM-CODE PIC X(2) 'LUE `-`.
BEGIN-QUL PIC X 'LUE (.
KEY-NME PIC X(8) 'LUE S#UKEY`.
#EL-OP# PIC X(2) 'LUE .
KEY-'LUE PIC X(2).
END-QUL PIC X 'LUE )`.
CMMAND CDES
Command Code Description
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
DL/I STATUS CDES
ist of Codes Common Status Codes
AB GK GB
AC GP End oI Database during Sequential retrieval using GN
AD II
AH IX GE
AI LB Segment ccurrence as deIined in a qualiIied SSA not
AJ LC Iound or not added in a ISRT due to error in SpeciIied path
AK LD
AM LE AI
A N Error in opening the database dataset
AT RX
AU V1 Spaces
DA SPACES Call ended normally
DJ
DX
GA
GB
GD
GE
Data Sensitivity
DBA
At a PSB level Ior SEGMENTS PRCPT
PCB TYPEDB,DBDNAME-SRCS,,KEYLEN11,PRCPT
SENSEG NAME SRU,PARENT0
SENSEG NAME CLIENT,PARENTSRU
Processing ptions : G, I, R, D, A, P, , N, T, E, L, GS, LS, H
At a PSB level Ior Iields
Done by DBA by use oI SENFLD macro , speciIying those Iields
that can be changed.
Programmer
At PRGRAM Level
- QualiIied 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 Ior Recovery Process
Are oI two types - Basic Checkpointing and Symbolic Checkpointing
Basic Checkpointing
CALL CBLTDLI` USING DLI-CHKP,
I--PCB-MASK,
CHECKPINT-ID.
Symbolic Checkpointing
Stores program data along with checkpoint records and retrieves that data
when program restarts aIter Iailure.
For extended Restart , an XRST call to be issued with the same Iields as in
CHKP call. It allows DL/I to retrieve the value in checkpoint record and
restores the speciIied Iields.
Explosive Mix - IMS DB with CICS
Scheduling Call
CICS Region / Partition
User Task
User InterIace Block
(UIB)
Program Communication
Block
(PCB)
A DL/I task must establish addressability to UIB and one or more PCB
IMS & CICS Continued
CALL CBLTDLI` USING FUNC-INIT
PSB-NAME
ADDRESS F DLIUIB
SET ADDRESS F PCB-ADDR-LIST T UIBPCBAL
SET ADDRESS F PCB-1 T PCB-1-ADR
SET ADDRESS F PCB-2 T PCB-2-ADR
....
User InterIace Block
Address oI PCB List
Address oI PCB 1
Address oI PCB 2
PCB Address list
PCB1
PCB2
Secondary Indexing
Employee Index Database
EMP..Seg
Addr
Employee ID
Index Pointer Segment
SRU
CLIENTS EMPLYEE
PRJECTS
Index Source Segment
Index Target
Segment
Same index Source segment and index target segment
Secondary Indexing Continued
Employee Index Database
SRU..Seg
Addr
Employee ID
Index Pointer Segment
SRU
EMPLYEE
Index Source Segment
Index Target
Segment
DiIIerent index Source segment and index target segment
CLIENTS
PRJECTS
Secondary Indexing Continued
Alternate sequencing is provided by storing pointers to Segments oI the indexed
Database in a separate secondary index data base
Secondary index data base has only one segment type - the Index pointer segment
which in turn contains a preIix element and a data element
PreIix element points to the index target segment
Secondary indexing is useIul Ior accessing segments were both
Index source segment and index target segment are same
Index source segment and index target segment are diIIerent
Two DBDGENS are required as a secondary database involves two database: one
Ior indexed database , the other Ior the secondary index database
Secondary Indexing Continued
DBDGEN - The Secondary Index code Ior SRCS DB
DBD NAMESRCS,ACCESS(HIDAM,VSAM)
DSG1 DATASET DD1DDSAT,DEVICE3380,SIZE4096,FRSPC0,15)
SEGM NAMESRU,PARENT0,BYTES40
FIELD NAME(SRUCD,SEQ,U),BYTES2,START1,TYPEP
..
SEGM NAMEEMPLY,PARENTSRU,BYTES80
LCHILD AAME (MYPA1R,MYDBD),POIA1ERIADX
FIELD NAME(EMPID,SEQ,U),BYTES5,START1,TYPEP
XDFLD AAMEMYIADX,SRCHEMPID
FIELD NAMEEMPNAME,BYTES25,START6,TYPEC
FIELD NAMEEMPPRJ,BYTES15,START31,TYPEC
FIELD NAMEEMPADDR,BYTES35,START46,TYPEC
...
Secondary Indexing Continued
DBDGEN - The Secondary Index code Ior Secondary Index DB
DBD NAMEMYIDBD,ACCESS(INDEX)
DSG1 DATASET DD1DDKAY,DEVICE3380,SIZE4096,FRSPC0,15)
SEGM NAMEMYPNTR,PARENT0,BYTES6
LCHILD AAME (EMPID,SRCS), IADXMYIADX
FIELD NAME(MYEMPID,SEQ,U),BYTES6,START1,TYPEC
DBDGEN
FINISH
END
PSB Requirements Ior Secondary Indexing.
PCB TYPEDB,DBDNAMESRCS,KEYLEN10,PRCPTLS,
P#OCSEQMYIDBD
SENSEG NAMEEMPLY
SENSEG NAMESRU,PARENTEMPLY
PSBGEN PSBNAMEMYSBX,LANGCBL
END
DiIIerence Between MPP , BMP & DLI
MPP (Message Processing Program)
For nline programs( IMSDC) only.
PSB used by a MPP program cannot be used by another programs simultaneously.
Cannot run on Individual partitions.
BMP (Batch message processing)
For batch programs only
PSB used by a BMP program cannot be used by another programs simultaneously.
All partitions speciIied in PSB will be allocated whether used by program or not.
Cannot run on Individual partitions.
DL/I
It can be used as InterIace between MPP and Database R BMP and Database
For batch DL/I job it can access database directly
PSB oI DL/I job can be used by another jobs simultaneously
It can run on Individual partitions.
HME

Вам также может понравиться