Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Skillwise-IMS DB

1,180 views

Published on

Information management system data base.

Published in: Technology
  • Login to see the comments

Skillwise-IMS DB

  1. 1. SKILLWISE-IBM IMS/DB IBM - Information Management System / Database
  2. 2. Course Content GAMA
  3. 3. Introduction • Database models (Relational / Hierarchical / Network) • Introduction to IMS • Database elements (Record, segment, path, field etc) • IMS Products • IMS Database types • Types of IMS Programs DB Models IMS Intro Elements Products IMS DB Types Programs GAMA
  4. 4. File and Database processing GAMA
  5. 5. Database Models • Relational – DB2, Oracle, etc • Hierarchical – IMS • Network – IDMS GAMA
  6. 6. Relational Model GAMA
  7. 7. Hierarchical Model GAMA
  8. 8. Network Model GAMA
  9. 9. Comparison of Relational & Hierarchical Model • • Relational Hierarchical Simple Structure Complex Structure Relationship represented by pointer Relationship represented by Key Optimized for 1 to many relationship Not optimized for any type of relationship Many to many relationship is handled by creating additional tree Many to many relationship is handled by creating additional table Date manipulation is handled through DL/1 Data manipulation is handled through SQL query DL/1 is a sequential record processing language SQL is a set processing language Programming is difficult since the programmer has to navigate through the database Programming is simple since SQL retrieves one table and hence navigation is easy IBM is the dominant vendor Many vendors No Standard ANSI Standard GAMA
  10. 10. IMS GAMA
  11. 11. Introduction to IMS  Maintain data integrity  Define the database structure and the relationships among the database elements  Query information in the database  Add new information to the database  Delete information from the database  Update information in the database  A central point of control and access for the IMS data that is processed by IMS applications  Facilities for securing (backup and recovery) and maintaining the databases GAMA
  12. 12. Elements of a File GAMA
  13. 13. COBOL Example GAMA
  14. 14. Relationship • Every record in the inventory file is related to one & only one record in the Vendor file • Each Inventory records has a maximum of 20 locations. • Issues – It is possible to add an inventory record without a Vendor record – Vendor record can be deleted without deleting the corresponding records in the Inventory file – Same location code may be used for 2 different locations within the same inventory. – Locations for a given Inventory records is expanded beyond 20, a system redesign will be required GAMA
  15. 15. COBOL Example GAMA
  16. 16. VSAM vs IMS GAMA
  17. 17. Hierarchical Database Model GAMA
  18. 18. DL/I To access the IMS DB from an application program we need an interface and i.e. DL/I. The Data Language Interface is an interface which deals with Data  Fetching,  Inserting and  Manipulating in IMS DB. GAMA
  19. 19. A Sample Inventory Database VENDOR ITEM CLIENT LOCATION IMS Terminology GAMA
  20. 20. Unit of data that DL/I transfers to and from your program in an I/O operation. A Segment type is a category of data. A Segment occurrence is one specific segment of a particular type containing user data. Segment GAMA
  21. 21. 01 INVVEN-SEG. 05 VENDOR_CODE 9(5). 05 VENDOR_NAME A(25). 01 INVITEM_SEG. 05 ITEM_CODE X(5). 05 ITEM_TYPE A(15). 01 INVLOC_SEG. 05 LOC_NAME A(35). 05 LOC_DIS X(31). VENDOR SEG. TYPE ITEM SEG.TYPE LOCATION SEG.TYPE Segment Layout GAMA
  22. 22. VENDOR ITEM CLIENT LOCATION ITEM ITEM CLIENT CLIENT LOCATIONLOCATION Segment Occurrences GAMA
  23. 23. The segment type at the top of the hierarchy is called Root Segment. All of the segments in a database record other than the root segment are Dependent Segments. Each occurrence of the root segment plus all the segment occurrences that are subordinate to it make up one Database Record. Root Segment, Dependant Segment & Database Record GAMA
  24. 24. V-1 IT-1 IT-2 L-2 L-1 L-2 L-1 V-2 IT-1 IT-2 L-2 L-1 L-2 L-1 Database Record-1 Database Record-2 Database Record GAMA
  25. 25. Each segment that has one or more dependent segment is a PARENT SEGMENT. Each dependent segment in the hierarchy is a CHILD SEGMENT. Two or more segment occurrences of the same type and with the same segment occurrence of their parent are TWIN SEGMENTS. Parent, Child and Twin GAMA
  26. 26. A Path is the series of the segments that lead from the top of a database record down to any specific segment occurrence. The path between two segments which would otherwise be unrelated is a Logical Relationship. Path GAMA
  27. 27. V-1 IT-1 IT-2 L-2 L-1 L-2 L-1 V-2 IT-1 IT-2 L-2 L-1 L-2 L-1 Path and Navigation GAMA
  28. 28. IMS uses a Key or Sequence field to refer to a segment as well as maintains the occurrences of the segments in ascending sequence based on this feild. Sequence fields can be unique or non unique. A search field is used to perform a search for a segment based on its contents. A search field cannot be used for sequencing. Sequence and Search Fields GAMA
  29. 29. Description of Data Base GAMA
  30. 30. Summarize GAMA
  31. 31. Logical Relationship GAMA
  32. 32. Secondary Index GAMA
  33. 33. Components of IMS The Database Manager (IMS DB)  DBMS The Transaction Manager (IMS TM)  Message based transaction processor A set of system services  Provide common services to the other two components. GAMA
  34. 34. IMS Interface – System Level GAMA
  35. 35. IMS Interface – Application Level Programming Environments Supported  COBOL  PL/1  Assembler  Java, using the IBM 31-bit SDK for z/OS, Java Technology Edition Application Programming Interfaces  Data Language/Interface (DL/I)  Java Database Connectivity (JDBC)  Java Message Service GAMA
  36. 36. Environments that can access IMS/DB  IMS Transaction Manager (IMS/TM)  CICS Transaction Server  Batch Regions (Batch Jobs)  Web sphere Application Server  DB2 for Stored Procedures GAMA
  37. 37. Classes of Databases • Full Function Database – Small or Large databases – Access to records via a unique or non-unique keys – Many types of segments (up to 15 level allowed) – Records can be stored in Key sequence but it is not a requirement. • Fast Path Databases – High data availability – Very high performance – Low processing cost GAMA
  38. 38. Types of Databases • Full Function Database – HSAM - Hierarchical Sequential Access Method – HISAM - Hierarchical Indexed Sequential Access Method – SHSAM - Simple Hierarchical Sequential Access Method – SHISAM - Simple Hierarchical Indexed Sequential Access Method – GSAM - Generalized Sequential Access Method – HDAM - Hierarchical Direct Access Method – PHDAM - Partitioned Hierarchical Direct Access Method – HIDAM - Hierarchical Indexed Direct Access Method – PHIDAM - Partitioned Hierarchical Indexed Direct Access Method – PSINDEX - Partitioned Secondary Index Database • Fast Path Database – MSDB - Main Storage Database – DEDB - Data Entry Database GAMA
  39. 39. Full Function Databases  Small or large databases.  Access to records via unique or non-unique keys.  Many types of segments (up to 15 levels allowed).  Records can be stored in key sequence, but it is not a requirement. GAMA
  40. 40. Data Entry Database  Large databases containing millions of records, extending well beyond the original 4GB database limits of DL/1 databases  Access to each database record that can be achieved by access via a key field  Lower processing costs per database record and per update than are required for DL/1 databases  The capability to support higher transaction workloads than DL/1 can sustain, while maintaining the per-transaction cost advantages mentioned above  Improved availability, with reduced requirements for database outage, especially for database maintenance activities such as database reorganizations GAMA
  41. 41. Main storage database: MSDB • To store the most frequently-accessed data • MSDBs reside in virtual storage, enabling application programs to avoid the I/O activity • MSDB segments are stored as root segments only • Only one type of pointer, the forward chain pointer, is used GAMA
  42. 42. Program Interface GAMA
  43. 43. IMS Programs • 2 Types of Programs – Batch • Executed through a normal operating system job • Name of the user program is passed as a parameter to the IMS Controller • The region is called the Batch Region – Online GAMA
  44. 44. IMS Batch Region GAMA
  45. 45. IMS Control Blocks
  46. 46. IMS Control Blocks • Review of File Access in COBOL • Overview of Control Blocks • DBD – Database Description • PSB – Program Specification Block • Structure of IMS Program Review Overview DBDPSB Program Structure GAMA
  47. 47. Review of COBOL file handling  FILE CONTROL  SELECT  ACCESS MODE  FILE STATUS RECORD KEY  FD  RECORD CONTAINS  Record Layout  Hierarchy  OPEN  File Name  Mode GAMA
  48. 48. IMS Control Blocks • Review of File Access in COBOL • Overview of Control Blocks • DBD – Database Description • PSB – Program Specification Block • Structure of IMS Program Review Overview DBDPSB Program Structure GAMA
  49. 49. Control Blocks A database description (DBD) is a control block that describes the physical structure of the database. The DBD also defines the appearance and contents, or fields, that make up each of the segment types in the database. A database program specification block (DB PSB) defines an application program’s view of the database. GAMA
  50. 50. Control Blocks Application Program PCB1 PCB2 PSB DBD1 DB1 DBD2 DB2 GAMA
  51. 51. IMS Control Blocks GAMA
  52. 52. IMS Control Blocks • Review of File Access in COBOL • Overview of Control Blocks • DBD – Database Description • PSB – Program Specification Block • Structure of IMS Program Review Overview DBDPSB Program Structure GAMA
  53. 53. DBD The DBD has the following information  Database Name  Segment names and lengths  Segment dependency information  Field names and lengths  Access Method GAMA
  54. 54. DBD Generation Process GAMA
  55. 55. DBDGEN Job //DBDGEN JOB MSGLEVEL=1 // EXEC DBDGEN,MBR=APPLPGM1 //C.SYSIN DD * DBD required for each DBD generation data set (or AREA) required for each data set group (or AREA in a Fast Path DEDB) Defines the physical characteristics of the data sets to be used for the database SEGM required for each segment type Defines a Segment type in the database Put in hierarchic sequence FIELD required for each DBD generation Defines a field in the segment GAMA
  56. 56. DBDGEN Job LCHILD required for each secondary index or logical relationship XDFIELD required for each secondary index relationship . . . DBDGEN required for each DBD generation END required for each DBD generation /* GAMA
  57. 57. DBD Generation Parameters DBD – Name • Names the database being described • 1 to 8 Alphanumeric characters SEGMENT – Name • Name of the Segment • 1 to 8 Alphanumeric characters – PARENT • Specifies the names of the Physical & Logical Parents – BYTES • Specifies the Length of the data portion GAMA
  58. 58. DBD Generation Parameters FIELD – Name • Field Name • 1 to 8 character alphanumeric value – SEQ • Identifies the field as a Sequence Field – Bytes • Length of the field in bytes – Start • Starting position GAMA
  59. 59. DBD Generation Parameters – Type • H for Hexadecimal • P for Packed Decimal Data • C for Alphanumeric • F for Full word binary • H for Half word binary GAMA
  60. 60. DBD Job Stream GAMA
  61. 61. DBD Job Strean GAMA
  62. 62. DBD Example GAMA
  63. 63. SKILL Database Definition DBD NAME=SKILLINV,ACCESS=HSAM DATASET DD1=SKILHSAM,DD2=HSAMOUT,BLOCK=1,RECORD=3000 SEGM NAME=SKILL,BYTES=31,FREQ=100 FIELD NAME=TYPE,BYTES=21,START=1,TYPE=C FIELD NAME=STDCODE,BYTES=10,START=22,TYPE=C SEGM NAME=NAME,BYTES=20,FREQ=500,PARENT=SKILL FIELD NAME=STDCLEVL,BYTES=20,START=1,TYPE=C SEGM NAME=EXPR,BYTES=20,FREQ=10,PARENT=NAME FIELD NAME=PREVJOB,BYTES=10,START=1,TYPE=C FIELD NAME=CLASSIF,BYTES=10,START=11,TYPE=C SEGM NAME=EDUC,BYTES=75,FREQ=5,PARENT=NAME FIELD NAME=GRADLEVL,BYTES=10,START=1,TYPE=C FIELD NAME=SCHOOL,BYTES=65,START=11,TYPE=C DBDGEN FINISH END GAMA
  64. 64. PAYROLL Database Definition DBD NAME=PAYROLDB,ACCESS=HSAM DATASET DD1=PAYROLL,DD2=PAYOUT,BLOCK=1,RECORD=1000, SEGM NAME=NAME,BYTES=150,FREQ=1000,PARENT=0 FIELD NAME=(EMPLOYEE,SEQ,U),BYTES=60,START=1,TYPE=C FIELD NAME=MANNBR,BYTES=15,START=61,TYPE=C FIELD NAME=ADDR,BYTES=75,START=76,TYPE=C SEGM NAME=ADDRESS,BYTES=200,FREQ=2,PARENT=NAME FIELD NAME=HOMEADDR,BYTES=100,START=1,TYPE=C FIELD NAME=COMAILOC,BYTES=100,START=101,TYPE=C SEGM NAME=PAYROLL,BYTES=100,FREQ=1,PARENT=NAME FIELD NAME=HOURS,BYTES=15,START=51,TYPE=P FIELD NAME=BASICPAY,BYTES=15,START=1,TYPE=P DBDGEN FINISH END GAMA
  65. 65. PSB • The PSB describes the way a database is viewed by your application program. • Specifies the – database segments an application program can access – functions it can perform on the data, such as read only, update, or delete. • PSBs are composed of one or more program control blocks (PCBs); one for each DB accessed GAMA
  66. 66. PSB Defining Multiple Databases GAMA
  67. 67. Same Database with 2 PCBs GAMA
  68. 68. PSB Example GAMA
  69. 69. PSB Example PCB TYPE=DB,DBDNAME=PARTMSTR,PROCOPT=A, KEYLEN=100,PCBNAME=NAME SENSEG NAME=PARTMAST,PARENT=0,PROCOPT=A SENSEG NAME=CPWS,PARENT=PARTMAST,PROCOPT=A SENSEG NAME=POLN,PARENT=PARTMAST,PROCOPT=A SENSEG NAME=OPERTON,PARENT=PARTMAST, PROCOPT=A SENSEG NAME=INVSTAT,PARENT=OPERTON,PROCOPT=A SENSEG NAME=OPERSGMT,PARENT=OPERTON PSBGEN LANG=COBOL,PSBNAME=APPLPGM1 END GAMA
  70. 70. PSB - PROCOPT • Processing Options – G - Get Function – I - Insert Function – R - Replace Function (includes G) – D - Delete Function (includes G) – A - All the options (G,I,R,D); default – L - Load Program – P - Path Call allowed GAMA
  71. 71. GAMA
  72. 72. PCB TYPE=DB,NAME=FISDBD1,PROCOPT=GRP,KEYLEN=20 SENSEG NAME=EMPLOYEE,PARENT=0 SENFLD NAME=EMPLNAME,START=13,REPL=NO SENFLD NAME=EMPFNAME,START=1,REPL=NO SENFLD NAME=EMPMI,START=11 SENSEG NAME=OFFICE,PARENT=EMPLOYEE SENSEG NAME=EMPLPROJ,PARENT=EMPLOYEE SENFLD NAME=PROJNUM,START=1 SENFLD NAME=PROJTITLE,START=10 SENFLD NAME=EPFUNCTN,START=35 SENFLD NAME=EPTIMEST,START=60 SENFLD NAME=EPTIMCUR,START =70 PSBGEN LANG=ASSEM,PSBNAME=FISPCB1 END GAMA
  73. 73. PSBGEN Process GAMA
  74. 74. Programs / DBD / PSB GAMA
  75. 75. Main Elements in an IMS Application Program • Program entry • PCB - Program Communication Block • I/O area definition • DL/I calls • Program termination GAMA
  76. 76. Structure of an Application Program GAMA
  77. 77. Program Entry PROCEDURE DIVISION USING PCB-NAME-1 [,...,PCB-NAME-N] • The procedure statement must refer to the – I/O PCB first, – then to any alternate PCB it uses, – and finally to the DB PCBs it uses. – The alternate PCBs and DB PCBs must be listed in the order in which they are defined in the PSB. • IMS passes control to the application program with a list of associated PCBs. GAMA
  78. 78. PCB GAMA
  79. 79. CALL Statement GAMA
  80. 80. PCB • IMS describes the result of a DB call in PCB • Program can not change the contents of PCB GAMA
  81. 81. PCB DBD Name Name of the Database Segment Level the level number of the last segment encountered Status Code A status code indicating the results of the DL/I call is placed in this field Processing Options •“processing intent” of the program against this database •four bytes long. Segment Name name of the last segment encountered Length of Key Feedback area current active length of the key feedback area Number of sensitive segments number of segment types in the database to which the application program is sensitive. Key Feedback area the concatenated key of the last segment encountered GAMA
  82. 82. PCB GAMA
  83. 83. GAMA
  84. 84. COBOL Programming Considerations for IMS/DB
  85. 85. COBOL Programming Considerations • Overview • Sequential Database Access – Input • Sequential Segment Access – Input • Random Access • Sequential Access for a given Parent • Update • Delete GAMA
  86. 86. Structure of an Application Program GAMA
  87. 87. Structure of an Application Program GAMA
  88. 88. Structure of an Application Program GAMA
  89. 89. CALL Statement CALL ‘CBLTDLI’ USING <Function>,<db PCB>,<I/o area>,<SSA> Function – 4 byte data item representing the DL/I function to be performed Db PCB – Data base PCB I/o area – The area to which the input data is to be moved SSA – Segment search argument GAMA
  90. 90. Function Codes GN GHN Get Next Get Hold Next Sequential Read GNP GHNP Get Next in parent Get hold next in parent Retrieve dependants sequentially GU GHU Get Unique Get Hold Unique To directly retrieve segments and to establish a starting position in the database for sequential processing. ISRT Insert to load a database and to add one or more segments to the database. REPL Replace change the values of one or more fields in a segment. DLET Delete to remove a segment and its dependents from the database. DEQ Dequeue to release a segment that is retrieved using the Q command code. GAMA
  91. 91. COBOL Programming Considerations • Overview • Sequential Database Access – Input • Sequential Segment Access – Input • Random Access • Sequential Access for a given Parent • Update • Delete GAMA
  92. 92. A Sample Inventory Database VENDOR ITEM CLIENT LOCATION Example - Hierarchy GAMA
  93. 93. 01 INVVEN-SEG. 05 VENDOR_CODE 9(5). 05 VENDOR_NAME A(25). 01 INVITEM_SEG. 05 ITEM_CODE X(5). 05 ITEM_TYPE A(15). 01 INVLOC_SEG. 05 LOC_NAME A(35). 05 LOC_DIS X(31). VENDOR SEG. TYPE ITEM SEG.TYPE LOCATION SEG.TYPE Example: Segment Layout GAMA
  94. 94. Example: Segment Layout GAMA
  95. 95. Example Write a IMS COBOL program to read all the segments of the VENDOR database to prepare a report as per the following format: Vendor Name: XXXXXXXXXXXXX Item Name: XXXXXXXXXXXXXX Location Code Quantity on Hand -------------------- ---------------------- XXX XXXX XXX XXXX XXX XXXX GAMA
  96. 96. COBOL Programming Considerations • Overview • Sequential Database Access – Input • Sequential Segment Access – Input • Random Access • Sequential Access for a given Parent • Update • Delete GAMA
  97. 97. Example Write a IMS COBOL program to read all the VENDOR segments of the VENDOR database to prepare a report as per the following format: Vendor Code Vendor Name ----------------- ----------------- XXX XXXXXXXXX XXX XXXXXXXXX GAMA
  98. 98. Unqualified GN Call GAMA
  99. 99. COBOL Programming Considerations • Overview • Sequential Database Access – Input • Sequential Segment Access – Input • Random Access • Sequential Access for a given Parent • Update • Delete GAMA
  100. 100. Example Write a IMS COBOL program to read all the ITEM segments of a given vendor to prepare a report as per the following format: Item Code Item Name ----------------- ----------------- XXX XXXXXXXXX XXX XXXXXXXXX GAMA
  101. 101. Segment Search Argument (SSA) • Function of SSA – Narrow the field of search to a particular segment type, or to a particular segment-occurrence. – Request that either one segment or a path of segments be processed. – Alter DL/I’s position in the database for subsequent call. • Maximum 15 SSAs allowed per call • Type of SSAs – Qualified – Unqualified • Contain only the name of the segment GAMA
  102. 102. Segment Search Arguments Segment Search Arguments (SSAs) specify information for IMS to use in processing a DL/I call. • Unqualified SSA – only a segment name. • Qualified SSA – Includes one or more qualification statements that name a segment occurrence. – The C command and a segment occurrence’s concatenated key can be substituted for a qualification statement. – C command & qualified SSA are mutually exclusive GAMA
  103. 103. Segment Search Argument (SSA) • Segment Name – Eight bytes long – Left-justified; trailing blanks required – As defined in the DBD • Command Codes – Optional. – Provide functional variations to be applied to the call for that segment type. – An asterisk (*) following the segment name indicates the presence of one or more command codes. – A blank or a left parenthesis is the ending delimiter for command codes. – Blank is used when no qualification statement exists. GAMA
  104. 104. Segment Search Argument (SSA) • Qualification statement – Presence is indicated by a left parenthesis following the segment name or, command codes (if present). – The qualification statement consists of a field name, a relational- operator, and a comparative-value. – “(“, indicates the beginning of a qualification statement. – Field name • is up to eight characters long, left-justified with trailing blanks as required. • must have been defined in the physical DBD. • may be either the key field or any data field within a segment. GAMA
  105. 105. Segment Search Argument (SSA) GAMA
  106. 106. SSA Example DATA DIVISION. WORKING-STORAGE SECTION. . . . 01 QUAL-SSA-MAST. 02 SEG-NAME-M PICTURE X(08) VALUE 'ROOT '. 02 BEGIN-PAREN-M PICTURE X VALUE '('. 02 KEY-NAME-M PICTURE X(08) VALUE 'KEY '. 02 REL-OPER-M PICTURE X(02) VALUE ' ='. 02 KEY-VALUE-M PICTURE X(n) VALUE 'vv...v'. 02 END-PAREN-M PICTURE X VALUE ')'. The SSA looks like this: ROOTbbbb(KEYbbbbbb=vv...v) GAMA
  107. 107. COBOL Programming Considerations • Overview • Sequential Database Access – Input • Sequential Segment Access – Input • Random Access • Sequential Access for a given Parent • Update • Delete GAMA
  108. 108. Commands C Supplies concatenated key in SSA D Retrieves or inserts a sequence of segments F Starts search with first occurrence L Locates last occurrence N Prevents replacement of a segment on a path call P Establishes parentage of present level GAMA
  109. 109. Qualified GN Call GAMA
  110. 110. GN with Qualified SSA GAMA
  111. 111. Basic REPL Call GAMA
  112. 112. Basic DLTE Call GAMA
  113. 113. Basic ISRT Call GAMA
  114. 114. Sample Path Call GAMA
  115. 115. Basic GU Call GAMA
  116. 116. Monitoring Position in Database • After you issue any kind of successful retrieval call, position is immediately after the segment occurrence you just retrieved – or the lowest segment occurrence in the path if you retrieved several segment occurrences using the D command code. • After a successful DLET call – position is immediately after the segment occurrence you deleted. – IMS deletes the dependents and the segment occurrence. • Current position is still immediately after the deleted segment occurrence • A successful REPL call does not change your position in the database. • After you add a new segment occurrence to the database, current position is immediately after the new segment occurrence. • If you retrieve several segment occurrences by issuing a Get call with the D command code, current position is immediately after the lowest segment occurrence that you retrieved. GAMA
  117. 117. Patient Database Example GAMA
  118. 118. Patient Segment GAMA
  119. 119. Illness Segment GAMA
  120. 120. Illness Segment GAMA
  121. 121. TREATMENT Segment GAMA
  122. 122. Question Where will be the pointer after the successful execution of the following command GU Abbbbbbb(AKEYbbbb=bA1) Bbbbbbbb(BKEYbbbb=bB11) Cbbbbbbb(CKEYbbbb=bC111) GAMA
  123. 123. Question Where will be the pointer after the successful execution of the following command ISRT Abbbbbbb(AKEYbbbb=bA1) Bbbbbbbb*D Cbbbbbbbb GAMA
  124. 124. Question Where will be the pointer after the successful execution of the following command GHU Abbbbbbb(AKEYbbbb=bA1) Bbbbbbbb(BKEYbbbb=bB11) Cbbbbbbb(CKEYbbbb=bC111) DLET GAMA
  125. 125. Position In addition to establishing current position after the lowest segment that is retrieved or inserted, IMS maintains a second type of position on one segment occurrence at each hierarchic level in the path to the segment you are retrieving or inserting. GAMA
  126. 126. Position after Unsuccessful calls • Unsuccessful DLET and REPL calls do not affect current position. • Unsuccessful Get call or ISRT call will affect the current position – Calls are processed level by level & the condition could have failed in one of the levels – Key feedback area MAY give keys at previous levels GAMA
  127. 127. Question Where will be the pointer after the successful execution of the following command GN Abbbbbbb(AKEYbbbb=bA1) Bbbbbbbb(BKEYbbbb=bB11) Cbbbbbbb(CKEYbbbb=bC113) GAMA
  128. 128. Multiple Qualification Statements • Up to 1024 qualification statements in a call • Logical AND coded as “*” or “&” • Logical OR coded as “+” or “|” GAMA
  129. 129. Multiple Qualification Statements Question: Did we see patient number 04120 during 1992? Answer: GU PATIENTb(PATNObbbEQ04120) ILLNESSb(ILLDATEb>=19920101&ILLDATEb<=19921231) GAMA
  130. 130. Multiple Qualification Statements Question: Did we see Judy Jennison during January of 1992, or during July of 1992? Her patient number is 05682. Answer: ?? GAMA
  131. 131. Multiple Qualification Statements Question: Did we see Judy Jennison during January of 1992, or during July of 1992? Her patient number is 05682. Answer: GU PATIENTb(PATNObbbEQ05682) ILLNESSb(ILLDATEb>=19920101&ILLDATEb<=19920131| ILLDATEb>=19920701&ILLDATEb<=19920731) GAMA
  132. 132. Concatenated Keys GAMA
  133. 133. COBOL Programming for IMS/DB
  134. 134. COBOL Programming Considerations • Overview • Sequential Database Access – Input • Sequential Segment Access – Input • Random Access • Sequential Access for a given Parent • Command codes • Multiple Qualification • Multiple Positions • Update • Delete GAMA
  135. 135. Multiple Qualification Statements • Up to 1024 qualification statements in a call • Logical AND coded as “*” or “&” • Logical OR coded as “+” or “|” GAMA
  136. 136. Patient Database Example GAMA
  137. 137. Patient Segment GAMA
  138. 138. Illness Segment GAMA
  139. 139. TREATMENT Segment GAMA
  140. 140. Multiple Qualification Statements Question: Did we see patient number 04120 during 1992? Answer: GU PATIENTb(PATNObbbEQ04120) ILLNESSb(ILLDATEb>=19920101&ILLDATEb<=19921231) GAMA
  141. 141. Multiple Qualification Statements Question: Did we see Judy Jennison during January of 1992, or during July of 1992? Her patient number is 05682. Answer: ?? GAMA
  142. 142. Multiple Qualification Statements Question: Did we see Judy Jennison during January of 1992, or during July of 1992? Her patient number is 05682. Answer: GU PATIENTb(PATNObbbEQ05682) ILLNESSb(ILLDATEb>=19920101&ILLDATEb<=19920131| ILLDATEb>=19920701&ILLDATEb<=19920731) GAMA
  143. 143. Multiple Qualification Statements Question: Did we see Judy Jennison during January of 1992, or during July of 1992? Her patient number is 05682. Answer: ?? GAMA
  144. 144. Multiple Qualification Statements Question: Did we see Judy Jennison during January of 1992, or during July of 1992? Her patient number is 05682. Answer: GU PATIENTb(PATNObbbEQ05682) ILLNESSb(ILLDATEb>=19920101&ILLDATEb<=19920131| ILLDATEb>=19920701&ILLDATEb<=19920731) GAMA
  145. 145. COBOL Programming Considerations • Overview • Sequential Database Access – Input • Sequential Segment Access – Input • Random Access • Sequential Access for a given Parent • Command codes • Multiple Qualification • Multiple Positions • Update • Delete GAMA
  146. 146. What is Multiple Processing • Multiple Positioning – Different Hierarchic Paths under a single root – B11, then C11, then B12, then C12 • Multiple PCBs – segments from different database records – retrieve a B segment under A1, and then a B segment under another A root segment. GAMA
  147. 147. Definition Single positioning means that IMS maintains position in one hierarchic path for the hierarchy that is defined by that PCB. When you retrieve a segment, IMS clears position for all dependents and all segments on the same level. Multiple positioning means that IMS maintains position in each hierarchic path in the database record that is being accessed. When you retrieve a segment, IMS clears position for all dependents but keeps position for segments at the same level. GAMA
  148. 148. Definition In multiple Positioning, more than one current position exist: IMS maintains a position at each level in all hierarchic paths, instead of at each level in one hierarchic path in the case of Single Positioning • To reset position, a GU call for a root segment should be given GAMA
  149. 149. Example GU Abbbbbbb(AKEYbbbb=bA1) Bbbbbbbb(BKEYbbbb=bB11) Cbbbbbbb(CKEYbbbb=bC111) GN Ebbbbbbb(EKEYbbbb=bE11) GAMA
  150. 150. Exercise GAMA
  151. 151. Exercise GAMA
  152. 152. Exercise GAMA
  153. 153. Exercise GAMA
  154. 154. Multiple PCBs • With multiple PCBs we can maintain positions in two or more database records and within two or more hierarchic paths in the same record. • Useful to compare information from segments in two or more database records. GAMA
  155. 155. Basic REPL Call GAMA
  156. 156. Basic DLTE Call GAMA
  157. 157. Basic ISRT Call GAMA
  158. 158. Monitoring Position in Database • After you issue any kind of successful retrieval call, position is immediately after the segment occurrence you just retrieved – or the lowest segment occurrence in the path if you retrieved several segment occurrences using the D command code. • After a successful DLET call – position is immediately after the segment occurrence you deleted. – IMS deletes the dependents and the segment occurrence. • Current position is still immediately after the deleted segment occurrence • A successful REPL call does not change your position in the database. • After you add a new segment occurrence to the database, current position is immediately after the new segment occurrence. • If you retrieve several segment occurrences by issuing a Get call with the D command code, current position is immediately after the lowest segment occurrence that you retrieved. GAMA
  159. 159. Question Where will be the pointer after the successful execution of the following command GU Abbbbbbb(AKEYbbbb=bA1) Bbbbbbbb(BKEYbbbb=bB11) Cbbbbbbb(CKEYbbbb=bC111) GAMA
  160. 160. Question Where will be the pointer after the successful execution of the following command ISRT Abbbbbbb(AKEYbbbb=bA1) Bbbbbbbb*D Cbbbbbbbb
  161. 161. Question Where will be the pointer after the successful execution of the following command GHU Abbbbbbb(AKEYbbbb=bA1) Bbbbbbbb(BKEYbbbb=bB11) Cbbbbbbb(CKEYbbbb=bC111) DLET
  162. 162. Position In addition to establishing current position after the lowest segment that is retrieved or inserted, IMS maintains a second type of position on one segment occurrence at each hierarchic level in the path to the segment you are retrieving or inserting. GAMA
  163. 163. Position after Unsuccessful calls • Unsuccessful DLET and REPL calls do not affect current position. • Unsuccessful Get call or ISRT call will affect the current position – Calls are processed level by level & the condition could have failed in one of the levels – Key feedback area MAY give keys at previous levels GAMA
  164. 164. Question Where will be the pointer after the successful execution of the following command GN Abbbbbbb(AKEYbbbb=bA1) Bbbbbbbb(BKEYbbbb=bB11) Cbbbbbbb(CKEYbbbb=bC113) GAMA
  165. 165. Loading the Database • Loading the database is done using an initial load program. • Initial load programs must be batch programs • What the Load Program does – Reads an input file containing the data to be loaded – Builds the segments for a database record – Inserts them into database in hierarchic order using the ISRT call • PROCOPT should be L GAMA
  166. 166. Loading the Database • For HSAM, HISAM, and HIDAM, the root segments must be presorted by the key fields of the root segments. • The only SSA you must supply is the unqualified SSA giving the name of the segment type you are inserting. • For HISAM and HIDAM, the key X'FFFF' is reserved for IMS. IMS returns a status code of LB if you try to insert a segment with this key. GAMA
  167. 167. Loading the Database • A sequence of segments can be inserted in one call by concatenating the segments in the I/O area and providing a list of unqualified SSAs. D command code should be coded for the first SSA. • A load program can be either Basic or Restartable • Restartable load programs must be run under control of the Utility Control Facility (UCF) GAMA
  168. 168. The Load Process GAMA
  169. 169. Basic Load Program - Logic GAMA
  170. 170. Load Program JCL // EXEC PGM=DFSRRC;;,PARM='DLI,your initial load programname,your PSB name' //DFSRESLB DD references an authorized library that contains IMS SVC modules //STEPLIB DD references library that contains your load program // DD DSN=IMS.RESLIB //IMS DD DSN=IMS.PSBLIB,DISP=SHR // DD DSN=IMS.DBDLIB,DISP=SHR //DBNAME DD references the database data set to be initially loaded or referenced by the initial load program //INPUT DD input to your initial load program GAMA
  171. 171. Status Codes for Load Programs LB The segment you are trying to load already exists in the database. DL/I only returns this status code for segments with key fields. LC The segment you are trying to load is out of key sequence. LD No parent exists for this segment. This status code usually means that the segment types you are loading are out of sequence. LE In an ISRT call with multiple SSAs, the segments named in the SSAs are not in their correct hierarchic sequence. V1 You have supplied a variable-length segment whose length is invalid.

×