IMS is the granddaddy of all transaction management and database systems. It is made up of a hierarchical database and an online transaction processing system. To know more about online systems, you may want to read one of my previous articles (Types of Processing on the Mainframe: Batch and Online). THIS ARTICLE IS COPYRIGHTED. IF YOU CAN READ THIS, THE ONE WHO POSTED THIS STOLE MY
IMS Hierarchical Database
The more popular databases today are relational databases. These are made up of tables related to other tables based on specific columns. Examples of relational databases are DB2, Oracle, MySQL and PostgreSQL. IMS is hierarchical in structure. An IMS database is made up of segments arranged in hierarchical order. An example of hierarchical arrangement of data is in XML.
In an IMS database, the topmost segment is called the root segment. Information relevant to the root segment are stored in child segments. For example, you want to store information about a client with many accounts. The top most segment will probably be information about your client (PERSON), such as name, address, contact number, etc.
The second level of segments might be the accounts they have. Each account will be one segment. Under accounts, you probably will have tra
nsactions for each account segment.
In this structure, the account segments would be children segments of the parent, the client segment. However, the account segments are parents of the transaction segments.
Data Base Definition (DBD)
Program Specification Block (PSB)
The PSB contains one or more Program Control Blocks (PCB). PCB's contain segments of a database accessed by the program. The number of PCB's depends on the number of databases to be used by the program. You need to define a PCB for every database you want to access in the program. You can also define the access allowed to a program in the PSB. The allowed accesses are GET, REPLACE, INSERT and DELETE or GRID for short.
Access Control Block (ACB)
THIS ARTICLE IS COPYRIGHTED. IF YOU CAN SEE THIS THE POSTER STOLE MY WORKWhen an IMS program executes, IMS has to merge the information in the DBD and PSB. The merged information is called an Application Control Block (ACB). For online applications, the merging of DBD and PSB information needs to be done quickly. This is why there is a need to perform an ACB gen. For Batch processing, there is no need to do an ACB gen since there is no need for fast response time.
As in everything on the mainframe, the naming convention for the DBD, PSB, field names and ACB will follow the mainframe naming convention. No more than 8 alphabetic and numeric characters with the first character being alphabetic character.
Accesing IMS Databases
Programs access relational databases through SQL statements. In IMS, you access the database through DL/1. DL/1 is basically a module that a program calls (similar to an API). You pass the access you want, the PCB you will use and search parameters. The DL/1 interface will interpret what you passed and will access the database for you and return the result.
Each programming language has its own way of calling the DL/1 interface.
To read a database segment, you use the GET function. There are several variations of the GET function. You can do a GET UNIQUE (GU), which means you get the first occurrence of the segment that matches your search criteria. You can do a GET NEXT (GN), that means you get the next segment. GET NEXT WITHIN PARENT (GNP) means you will get the next segment within the same parent.
To update a segment, you need to read it and hold on to the segment. You do this by using the GET HOLD UNIQUE (GHU), GET HOLD NEXT (GHN) and GET HOLD NEXT WITHIN PARENT (GHNP).
You can also insert a segment using the insert (ISRT) function. To replace fields within a segment, use the replace (REPL) function. And to delete a segment, use the delete (DLET) function.
IMS logs all updates to your database by using a log. The log can be used to recover the database to a certain point in time. The log basically contains the before and after image of a segment so it can be used to backout updates or forward recover from an image copy.
What Languages Can Work with IMS
Aside from the traditional mainframe languages like COBOL, Assembler and PL/1, you can also use Java to access an IMS database.
If you want to learn more about IMS database programming, you can read the Programming for IMS manual.