Idms Integrated Database Management System
Idms Integrated Database Management System
Idms Integrated Database Management System
Integrated Database
Management
System
Topics Covered
Introduction to DBMS
Logical and Physical Database Structure
Record Characteristics
Set Characteristics
IDD and DDDL
Data Description Language (DDL)
Data Manipulation Language (DML)
Recovery & Restart of Database
Locking Facilities
2
Introduction to DBMS
3
TYPES of DBMS
Inverted List (e.g. Datacom DB)
4
Continue …..
• Network (e.g. IDMS)
The database forms a mesh structure
Entity-Relationship is implemented
using Record type and Set.
5
Logical & Physical
Database Structure
6
LOGICAL DATABASE STRUCTURE
SALARY TEAM
PLAYER GAME
BONUS
8
THE EXAMPLE
The example discussed here:
Taken from a typical American baseball
league.
A team has many players but at a given
time, a player is attached to only one team.
A team plays many games. Games can be
further identified by Game-Home and
Game-Away.
9
Continue …..
A player plays many games and same way
a game is played by many players.
A player has many salary records since his
salary (contracts) may have undergone
changes during a season. Similarly, a
player might have many bonuses awarded
to him.
Team, Player, Game, Salary and Bonus
represent Entities.
10
Continue …..
Attributes of Team could be Team-
Name, Team-City, Team-Address etc.
The relationship between entities is
shown by line diagram. We use
cardinality symbols to represent type of
relationship. The crow-foot end of the
line diagram represents Many type and
single line represents One type of the
relationship.
11
Continue …..
For example, consider relationship
between Team and Player. Team end
has a single line whereas Player end
has a crow-foot. This represents a
One-to-Many relationship. It means a
team has many players. But a player
is attached to only one team.
Note that relationship between Player
and Game is Many-to-Many. i.e a
game has many players and a player
plays many games.
12
Continue …..
13
JUNCTION RECORD
It is a way of implementing many-to-
many relationship in IDMS. It is a
record type having attributes that are
common (intersection) to both record
types participating in many-to-many
relation.
Thus, many-to-many relation between
player and game can be resolved as
below.
14
Continue …..
PLAYER GAME
POSITION
NOTE:
Here, referring to our earlier example of
American baseball league, we had many-
to-many relationship between entities
player and game.
15
Continue …..
16
Continue …..
A player has many positions assigned to
him for different games. But for a game
he has a fixed position. Main attribute of
the record is “player-position” for a
game. It thus resolves many-to-many
relationship between player and game.
In other words, we can easily move
from a player record occurrence to a
game record occurrence using the
position record occurrence.
17
BACHMAN DIAGRAM
Most installations use a line with an arrow
at one end to show each one-to-many
relationship instead of using crow’s foot
notation. Such a diagram is called
Bachman Diagram. Here, the end of the
relationship without an arrow always
represents “One” side of the relationship
and the end with arrow always represents
“Many” side of the relationship.
Our earlier E-R diagram is represented
using Bachman diagram as:
18
BACHMAN DIAGRAM
TEAM
SALARY
PLAYER GAME
BONUS POSITION
19
PHYSICAL DATABASE STRUCTURE
Database Area, Page and File
21
Continue …..
Page size for an area is decided based
on the record types that will be
residing within that area.
ALL record occurances of a
particular record type are stored
within the SAME area.
But, an area may store occurances of
multiple record types. Hence this
holds true for a database page as well.
22
Continue …..
Record types are assigned to areas by
designer.
Areas are mapped to files.
Many or all areas can be mapped
into one file if all areas have the
same page size.
Each area can be mapped into a
different file.
One area can be mapped into
several files.
23
AREAS and FILES MAPPING
Area
File
Physical Database
Block
24
Area and File Mapping…..
Team Area Position Area Salary Area
921 922 … 930 1021 1022 … 1040 821 822 ... 830
25
ADVANTAGES OF MULTIPLE AREAS
TEAM-AREA
SALARY
TEAM
PLAYER GAME
BONUS
POSITION
SALARY-AREA
POSITION-AREA
26
Continue …..
As shown in the previous slide, our
example of baseball database is divided into
three physical areas namely Team-area,
Position-area and Salary-area.
The advantages of dividing a database into
separate physical areas are:
Processing efficiency
Records those are accessed together
during most of the processing can be
grouped together into same area for
efficiency. 27
Continue …..
Security
One can restrict access to certain
record types. e.g. salary-area can be
restricted to only finance department.
Database recovery and backup
Database can be initialized,
reorganized and backed up on area-
by-area basis. Backup of most
updated areas can be made more
frequent than other areas.
28
Continue …..
Concurrent updating
A program can request exclusive
use of an area and prevent other
programs from accessing it
concurrently.
29
CONCEPT of DB-KEY
Each Record occurrence stored in the
database is assigned an unique numeric
identifier, called Database Key (db-key).
A record’s db-key consists of a 32-bit field
that contains a 23-bit page number and an
8-bit line number. The page number
identifies the page in which the record is
stored and the line number identifies
location of the record occurrence within
the page.
The format of db-key is as below:
30
Sign Bit Database Page Number Line Number
1-bit
23-bits 8-bits
(Not
Used)
31
RECORD TYPE v/s RECORD
OCCURRENCE
It is important to make distinction
between Record Type and Record
Occurrences.
Record type is like a template. It
describes the format of all occurrences of
a given record type stored in database.
Record occurrence represents the smallest
directly addressable unit of data. It
consists of fixed or variable number of
characters that are subdivided into units
called Data Elements.
32
Example of Record Type versus Record
Occurrences
Employee Record Type ……….
35
Continue …..
Data elements values are stored in data
portion. Pointers to related record
occurrences are stored in prefix portion.
Application programs deal only with data
portion of the record occurrence.
Whereas, IDMS system maintains the
pointers in the prefix portion.
36
SCHEMA and SUBSCHEMA
37
Continue …..
A subschema defines a subset of the
schema. One or more subschemas can
be associated with a schema. A load
module is created for each subschema.
At runtime, a program can access only
one subschema. A program can not
access IDMS database by referring to
the schema.
A subschema is similar to a view in a
relational database.
38
Continue …..
Even if a program requires access to
ALL record types, data elements and
ALL set types defined in the schema,
the designer must still define a
subschema that includes all the
entities defined in the schema.
A subschema can restrict access to a
program. For example, it may give
only read-only access to an area, or it
may not allow deletion of some record
types.
39
Record Characteristics
40
The characteristics that apply to record
types are:
Record Name
Record Identifier
Storage Mode
Record Length
Location Mode
Duplicates Option
Area Name
41
RECORD NAME
Each record type must be assigned a 1
to 16 character name that identifies the
record type. The name must begin with
an alphabetic character. The
application program must reference the
record’s name in DML (Data
Manipulation Language).
42
RECORD IDENTIFIER
It is a number that serves as in internal
identifier for the record type. It is in the
range 100 through 9999. Each record
type must be assigned an unique record
identifier within the installation. DBAs
assign this number to each record type.
Application programs do not refer to
record type using this number.
43
STORAGE MODE
It indicates whether record occurances
of the record type are fixed or variable
length and whether they are stored in
compressed format.
Allowable codes are:
F (fixed length)
V (variable length)
C (compressed)
44
Continue …..
NOTE:
Compressed mode can be used along
with fixed or variable length storage
modes. For example, one can mention
storage mode as ‘FC’ or ‘VC’. DBMS
takes care of compression and
decompression of data.
45
RECORD LENGTH
46
LOCATION MODE
It defines the way record occurances
are stored in the database.
Allowable location modes are:
CALC
VIA
DIRECT
47
CALC Mode
In CALC mode, a particular data
element within the record is declared as
the CALC-key. At the time of storing
the record in the database, IDMS
system uses value of the data element
to calculate the page number for
storing a record. Records stored with a
CALC mode can be retrieved from disk
in a single access.
48
Continue …..
IDMS system uses randomizing routine
to distribute records evenly over its area,
minimizing overflow conditions and
leaving space for adding new records.
For retrieving the record (stored with
CALC location mode), appropriate
value for the data element is moved to
the storage area in the application
program and then DML retrieval
function is executed. 49
VIA Mode
Records stored with VIA location mode
are stored near another database record.
This mode is generally used for storing
member records on the same page
containing owner record or on a page
near their owner record.
This mode tends to reduce disk accesses
needed to retrieve all the records of a set
occurrence.
50
Continue …..
51
DIRECT Mode
54
Continue …..
DF (Duplicates First)
DL (Duplicates Last)
57
Data Structure Diagram (DSD) for
Documenting Record Characteristics
Record name
Area name
58
Example : DSD for Employee Record
Type
EMPLOYEE
EMP-CODE DN
HR-AREA
59
Set Characteristics
60
WHAT IS A SET ?
A Set consists of an OWNER record
type and one or more MEMBER record
types.
SET OCCURRENCE ?
61
Walking a Set
Records in each set occurrence are
physically linked together by pointers.
Accessing members by following the
pointers from one record occurrence to
the next is called Walking the Set.
Empty Set Occurrence
A set occurrence that consists only of an
owner record occurrence and no
member record occurrences is called
Empty Set occurrence.
62
RULES & FEATURES FOR SET
RELATIONSHIP
• Any record type can be member in one
or more sets.
• Any record type can be owner of one or
more sets.
• Any record type can be member in one
set and owner in another set.
• An owner record can own the same
member record in more than one set.
• A record cannot be both owner and
member in the same set.
63
Any record type can be member in one or more sets
Department Office
Dept-Employee Office-Employee
Employee
64
Any record type can be owner of one or more sets
Customer
Cust-Order Cust-Parts
Order Parts
65
Any record type can be member in one set and
owner in another set
Customer
Cust-Order
Order
Ord-Items
Items
66
An owner record can own the same member
record in more than one set
Teacher
Teach-Class Examiner-Class
Class
67
Set Characteristics
DBA typically assigns characteristics to
each set when defining the IDMS
database in the schema DDL.
The characteristics are:
Set Name
Linkage Options
Membership Options
Order Option
Duplicates Option
68
SET NAME
70
Continue …..
N (NEXT pointer)
Each record in the set contains a
pointer to the next record
occurrence. This option allows to
access member records only in the
forward direction. Next pointer is
mandatory for all sets. All other
pointers are optional.
71
Continue …..
72
Continue …..
73
Continue …..
74
Office
Office-Employee
Employee
N P O EMP-A DATA
N P O EMP-B DATA
N P O EMP-C DATA
75
MEMBERSHIP OPTIONS
The Membership options specify how a
member record may be connected to or
disconnected from a set occurrence.
The option is defined in two parts.
First part is a Disconnect Option,
indicating the way a record is
disconnected from a set.
Second part is the Connect Option,
indicating how a record is connected to
a set.
76
Disconnect Option
It specifies whether a member record can
be later disconnected from a set once its
membership has been established.
Possible values are:
M (Mandatory)
The record cannot be disconnected
from a set unless that record is
deleted (erased) from the database
using the ERASE command.
77
Continue …..
O (Optional)
A record occurrence can be
disconnected from a set. The
record remains in the database. It
can be connected to some other
set occurrence. It is optional to
use ERASE for such records.
78
Connect Option
M (Manual)
Manual option specifies that after
inserting a record, programmer
must explicitly connect it to its
owner record by issuing
CONNECT statement.
80
Combinations for Membership Options
MA - Mandatory Automatic
MM - Mandatory Manual
OA - Optional Automatic
OM - Optional Manual
81
ORDER OPTION
The order option specifies logical order
in which member record occurrences
are placed within a set occurrence.
Options available are:
FIRST
Each new member record
occurrence is placed immediately
after the owner record (in the next
direction). This option achieves a
member record in LIFO.
82
Continue …..
LAST
Each new member record occurrence
is placed immediately before the
owner record (in the prior direction).
This option achieves a member record
in FIFO. Prior pointer is a must to
specify this option.
NEXT
Each new member record occurrence
is placed immediately after the
member record occurrence that was
last accessed (in the next direction). 83
Continue …..
PRIOR
Each new member record occurrence
is placed immediately before the
member record occurrence that was
last accessed within the set (in the
prior direction). Prior pointer is a
must to specify this option.
84
Continue …..
SORTED
Each new member record occurrence
is placed in ascending or descending
sequence, based on the value of
designated sort-control data element
(sort-key) in each record occurrence.
When the record is placed into a set,
DBMS examines the sort-key value
in each member to find the logical
position of new member record in
the set.
85
DUPLICATES OPTION
This option is useful only in case where
set is defined with order option as Sorted.
It indicates the action to be taken when a
duplicate sort-key value occurs.
DN (Duplicates Not Allowed)
Record occurances with duplicate
sort-key value will not be stored in
the set. IDMS returns an error code
if program tries to store such a
record.
86
Continue …..
DF (Duplicates First)
87
Continue …..
DL (Duplicates Last)
88
INDEXED SETS
IDMS allows retrieval of records using
an index.
In conventional sets, member records
are chained together by pointers. In an
indexed set, DB-key values of member
record occurrences are stored in a
specified order in one or more index
records.
Adds flexibility to data retrieval and
retrieval is made faster in some cases.
89
Continue …..
Indexed sets are useful in cases where:
Records need to be accessed using
91
Continue .....
User-defined
Owner Record Player
Player-Position-Index
(Position-Name)
Position
92
Continue .....
SR7
System-defined owner
record
(Employee-Name)
Employee
93
Continue …..
94
TEAM-PLAYER TEAM-GAME
NPO NPO
SALARY
OM TEAM
MM
2000 F 40 VIA LAST 1100 F 80 CALC NEXT
PLAYER-SALARY TEAM-NAME DN
SALARY-AREA TEAM-AREA
PLAYER-SALARY
NPO
OA
PLAYER GAME
NEXT
1000 F 70 CALC 1200 F 70 CALC
96
INTEGRATED DATA DICTIONARY (IDD)
IDD stores meta-data about all the data items
in the database (The data values are not stored
in IDD).
Stores information about users, application
programs, files, record, data element, module
(date routine, error handling routine) and
application systems.
99
Examples of DDDL
100
Continue …..
MODIFY ELEMENT CITY-NAME
PICTURE X(25).
101
Data Description
Language (DDL)
102
Data Description Language (DDL) is
used to define:
SCHEMAS
DBA describes the logical
structure of the database by coding
set of schema DDL statements.
There is a single schema for a
given database.
103
DEVICE-MEDIA CONTROL
LANGUAGE (DMCL) MODULES
Many aspects of the database’s
physical structure, such as disk
device assignments and page sizes
are described in DMCL module
definition.
104
SUBSCHEMAS
The views that individual
applications programs have of the
database are defined in
subschemas and described with set
of subschema DDL statements.
Any number of subschemas can be
defined for a given database.
105
SCHEMA DDL STATEMENTS
The logical structure of a database is defined
in a set of schema DDL statements.
Schema DDL statements define the
following:
Schema name
Database file names
Database areas
Data elements and records
Sets
106
Process
The schema DDL is processed by the
schema compiler. The schema
compiler reads the schema DDL
statements and stores a description of
the schema in the data dictionary.
The data dictionary is the central
repository of information that IDMS
maintains about the databases under its
control.
107
Continue …..
The schema compiler can also copy from
the data dictionary descriptions of records
that have been previously defined and
stored in the data dictionary.
Schema
Schema Data
DDL Compiler Dictionary
Statements
108
Example Of Schema DDL
ADD SCHEMA NAME IS DDSCHEMA VERSION 1
111
DMCL DDL STATEMENTS
It completes the mapping of logical areas
into physical files.
It also identifies and describes the journal
files that are used by IDMS for recording
changes made to the database. Journal
files are used to implement IDMS backup
and recovery facilities.
112
Continue …..
DMCL DMCL
Source Compiler Data
Statements Dictionary
Assembler
Load
Linkage Library
Editor
116
Continue …..
DMCL DDL statements contain following
four sections:
Device-Media Description section
119
Continue …..
AREA SECTION.
COPY SALARY-AREA AREA
BUFFER IS XXBUFF
JOURNAL SECTION.
JOURNAL BUFFER IS JJBUFF.
FILE CONTAINS 3000 BLOCKS.
FILE NAME IS XANJRNL1
ASSIGN TO SYSJRNL1.
FILE NAME IS XANJRNL2
ASSIGN TO SYSJRNL2.
120
SUBSCHEMA DDL STATEMENTS
module name
Areas accessible in this
subschema
Records and data elements
accessible and
Sets included in the subschema
121
Process
The subschema compiler reads
subschema source statements and
stores a description of the subschema
in the data dictionary.
The compiler also stores an executable
load module in an area of the data
dictionary, known as Load Area.
IDMS uses this load module whenever
an application program using this
subschema is under execution.
122
Continue …..
Like DMCL compiler, subschema
compiler must have access to the
corresponding schema definition in the
data dictionary. Thus, schema must
have been compiled before any of its
associated subschemas can be
compiled.
After compiling subschema, data
dictionary has all the required
information about the logical and
physical structures of the database.
123
Continue …..
Load Area
124
Example Of Subschema DDL
ADD SUBSCHEMA NAME SUBSCHA OF SCHEMA
NAME SCHDBA VERSION 1
DMCL NAME SUBADMCL OF SCHEMA NAME
SCHDBA VERSION 1
COMMENTS ‘LIMITED VIEW OF SCHDBA’
125
Data Manipulation
Language
(DML)
126
In an IDMS application program, there
are no file description statements or Open
and Close statements found in a typical
batch Cobol file processing application
system.
To access data stored in the database,
DML verbs are used.
Two new terms Run Unit and Currency
are important to understand.
127
CONCEPT of RUN UNIT
128
Continue …..
130
Continue …..
Currency is established by DML verbs
FIND, OBTAIN, STORE,
CONNECT, DISCONNECT and
ERASE.
There are four currencies maintained
for a database:
current of run unit
current of record type
current of set
current of area
131
Continue …..
Current of Run Unit is a record
which was most recently accessed.
Current of Record type is the most
recently retrieved or inserted record
of that record type.
Current of Set is the most recently
retrieved or stored record of that
set. Record may be a member or
owner of that set.
132
Continue …..
Current of Area is the most recently
retrieved or stored record of that area.
133
IDMS APPLICATION PROGRAM PREPARATION
Source DML
Statements Processor Data
Dictionary
Compiler
Load
Linkage Library
Editor
134
The previous slide shows how an IDMS
application program written in Cobol host
language is compiled and made ready for
execution.
Application program with embedded
DML statements is first read by DML
processor. It validates DML statements
and creates translated version of the source
program where in DML statements are
replaced by appropriate calls to IDMS.
135
Continue …..
DML processors are available for a
number of commonly used programming
languages. DML processor may also
generate a listing of errors. DML
processor interacts with data dictionary
for copying descriptions of various
database elements like schema,
subschema, record types etc.
Output from the DML processor acts as
input to the host programming language
compiler like a Cobol compiler.
136
Continue …..
138
Continue …..
DATA DIVISION begins with
SCHEMA SECTION which gives
the subschema used by the
program.
PROCEDURE DIVISION has
DML verbs for data retrieval and
data updation.
139
IDMS-CONTROL SECTION
.….
ENVIRONMENT DIVISION.
IDMS-CONTROL SECTION.
PROTOCOL.
MODE IS BATCH DEBUG.
IDMS-RECORDS WITHIN WORKING-STORAGE SECTION.
CONFIGURATION SECTION.
…..
INPUT-OUTPUT SECTION.
FILE CONTROL.
…..
140
Continue …..
142
Continue …..
144
Continue …..
148
COPY STATEMENT
149
Continue …..
151
Continue …..
FINISH.
159
Continue …..
CALC-key Retrieval
To perform Calc-key retrieval, the record
must have location mode specified as
CALC and we must know the Calc-key
value for the record to be retrieved.
160
Continue …..
162
Continue …..
164
Continue …..
165
Continue …..
168
Continue …..
169
Continue …..
170
Continue …..
171
Continue …..
Sort-Key Retrieval
182
Continue …..
183
Continue …..
186
Continue …..
189
Continue …..
Making the record to be modified
as current of run unit. This is done
by retrieving the record before
modifying it, by issuing Obtain.
190
Continue …..
MOVE INPUT-EMP-CODE TO EMPLOYEE-CODE.
OBTAIN CALC EMPLOYEE.
IF DB-STATUS-OK
MOVE NEW-EMP-ADDRESS
TO EMPLOYEE-ADDRESS
MODIFY EMPLOYEE
PERFORM IDMS-STATUS.
191
STORE STATEMENT
192
Continue …..
193
Continue …..
STORE EMPLOYEE.
194
Continue …..
196
ERASE STATEMENT
197
Continue …..
198
Continue …..
ERASE
We first begin by retrieving the record
we want to delete and thus the record is
made current of run unit. Then Erase is
issued naming the record type.
The record is first disconnected from all
sets in which it participates as a
member.
199
Continue …..
200
Continue …..
MOVE INPUT-EMP-CODE TO EMPLOYEE-CODE.
OBTAIN CALC EMPLOYEE.
IF DB-STATUS-OK
ERASE EMPLOYEE
PERFORM IDMS-STATUS.
201
Continue …..
202
Continue …..
204
Continue …..
205
Continue …..
206
CONNECT STATEMENT
209
QUEUE RECORDS
We write temporary data to a queue
record in data dictionary and make this
data available to other IDMS COBOL
programs (DC-BATCH Mode).
Queue records are relatively
permanent records in that they are not
deleted when the system is shutdown
or when the system crashes. They are
deleted either explicitly by
programmer or after the retention
period specified for the queue is over.
210
Continue …..
211
QUEUE MANAGEMENT COMMANDS
212
Continue …..
213
Continue …..
214
Continue …..
215
MAJOR CODES OF ERROR-STATUS
01 : FINISH
02 : ERASE
03 : FIND/OBTAIN
05 : GET
06 : KEEP
07 : CONNECT
08 : MODIFY
09 : READY
216
Continue …..
11 : DISCONNECT
12 : STORE
14 : BIND
18 : COMMIT
19 : ROLLBACK
217
Recovery and Restart
of Database
218
IDMS provides facilities for recovering
from problem situations and for restarting
after failures occur.
Journal files are used for the recovery
and restart facilities.
These facilities are dependant on the two
operating environments in which an
IDMS run unit executes.
219
IDMS OPERATING ENVIRONMENTS
IDMS application program can be run in
two operating environments: Local Mode
and Central Version.
All online applications that use IDMS/DC
or some other telecommunication facilities
must run under central version.
An application program that operates in
batch mode can be run either under the
control of central version or in local mode.
220
Central Version
In central version, a single copy of the
IDMS DBMS controls the operation of a
particular set of IDMS application
program run units.
No two central version are allowed to
update the same database area. All run
units that execute under the control of a
particular central version are chosen such
that they all access the same group of
database areas.
221
Continue …..
Multiple copies of IDMS central version
can execute in same region with each
copy accessing different set of database
areas.
Central version implements facilities for
recovering from system failures.
It is the preferred method of running an
IDMS application.
222
Local Mode
A batch program that operates in local mode
has its own copy of IDMS DBMS loaded
into its partition, region or address space.
IDMS provides no automatic restart and
recovery facilities for applications running
in local mode.
Batch retrieval programs are good
candidates for running in local mode.
An application runs faster in local mode.
223
JOURNAL FILES
IDMS maintains set of journal files that
are used to recover from failures and to
restart aborted run units.
IDMS provides automatic restart and
recovery facilities for applications
running under central version AND for
run units those use journal files.
Journal files can be put on disk or tapes.
224
CHECKPOINTING
When a run unit begins by issuing BIND
run-unit statement, IDMS system writes
Begin checkpoint record on the journal
file. This contains information about
current status of the run-unit.
As run-unit executes, it may update
records in database. As each update
request is processed, IDMS writes
Before Image and After Image of the
updated record to the journal file.
225
Continue …..
When applications ends the run-unit by
issuing FINISH statement, IDMS writes
End checkpoint record on to the journal file.
Thus, at the end of execution of a run-unit
the journal files contains:
Begin checkpoint
Before and After images of all
updated records and
End checkpoint
226
RECOVERY and RESTART
Following are typical scenarios when run
unit is terminated abnormally.
Program error may cause the run unit
to terminate abnormally.
IDMS system may encounter
situations that require it to terminate
one or more run units abnormally. e.g.
Wait time limit has been exceeded to
avoid deadlock.
227
Continue …..
230
INTERMEDIATE CHECKPOINTS
232
THE COMMIT VERB
Commit verb is used to write Intermediate
checkpoints on the journal file.
There are two forms of Commit verb:
COMMIT and
COMMIT ALL
233
Continue …..
In COMMIT, IDMS releases all locks
except those placed on current records.
In COMMIT ALL, IDMS releases all
locks including those on current records.
In case of abnormal termination of run
unit, IDMS works backwards in the
journal file and reads till the most recent
COMMIT checkpoint is encountered.
234
Continue …..
237
ROLLBACK CONTINUE
238
Locking Facilities
239
Locking facilities are provided for
controlling access to areas and to individual
records when two or more run units require
access to the same database areas.
IDMS provides three levels of locking
facilities.
Area Locks
Area Usage Modes
Record Locks
240
AREA LOCKS
Area locks are used to prevent areas
from being updated by more than one
IDMS central version or by more than
one application running in local mode.
If an area is locked that is required by a
local mode application, that local mode
application ABENDS.
241
Continue …..
242
Continue …..
If required area is locked that is
required by an IDMS central version,
execution of that central version
continues, but no run-unit executing
under the control of that central version
will be given access to the already
locked area. The area is said to be
Varied Offline to that central version.
Run-units that attempt to access an area
that is varied offline are abnormally
terminated.
243
Continue …..
If required areas are NOT locked, then
those areas are locked by the central
version. Run-units executing under the
control of that central version can
access those areas. No other central
version will be given access to locked
areas.
An area that is locked by a central
version is released only when the
central version is shut down.
244
AREA USAGE MODES
245
Continue …..
(Shared) Retrieval
Protected Retrieval
Exclusive Retrieval
(Shared) Update
Protected Update
Exclusive Update
247
Protected Retrieval
250
Protected Update
We are requesting update access to the area and
specifying that other run units should not be able
to update records in the same area till our run unit
finishes. All other run units will be allowed to
retrieve records in the same area as long as they
do not specify Protected or Exclusive as usage
modes.
252
Run Unit 2
Protected Retrieval
Exclusive Retrieval
Protected Update
Exclusive Update
Shared Retrieval
Shared Update
Shared Update Y Y N N N N
Shared Retrieval Y Y Y Y N N
Run Unit 1
Protected Update N Y N N N N
Protected Retrieval N Y N Y N N
Exclusive Update N N N N N N
Exclusive Retrieval N N N N N N
253
IMPLICIT RECORD LOCKS
254
Continue …..
Record locks are generally maintained
for shared and protected update mode
and shared retrieval mode.
Implicit locks can be either Shared or
Exclusive.
Implicit Shared lock guarantees that only
one run-unit is allowed to update a
record while others can retrieve the same
record.
Implicit Exclusive lock ensures that no
other run-unit can either update or
retrieve the record.
255
Continue …..
Implicit shared locks is placed on a
record when it is retrieved and
Implicit Exclusive lock is placed on a
record when it is accessed through a
DML update verb.
Shared Lock remains in effect till
currency changes.
Exclusive Lock remains in effect till
run-unit ends (Finish) or until
Commit is issued.
256
EXPLICIT RECORD LOCKS
Explicit locking is the most efficient way of
placing record locks. It can be set by coding the
KEEP statement or by the KEEP clause of the
FIND/OBTAIN statement.
Explicit lock remain is effect until Finish is
executed or Commit is issued.
e.g. Obtain Keep Calc Employee.
Obtain Keep Exclusive Calc Employee.
First is explicit shared lock and second is
explicit exclusive lock.
257
Continue …..
258