《【精品】IMS Database精品ppt课件.ppt》由会员分享,可在线阅读,更多相关《【精品】IMS Database精品ppt课件.ppt(89页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、IMS DatabaseDay 1-Topics CoveredWhat is IMS DBSome General ConceptsDBD PSBWhat is IMS DBIMS Information Management SystemHierarchical StructureEach Box in the hierarchy represents a segmentB3A2D1B2A1C1ROOT SEGMENT(PARENT)SEGMENT OCCURRNCESTWIN SEGMENTSDEPENDENT SEGMENTS-Level 1-Level 2B1HIERARCHICAL
2、 STRUCTUREIMS GENERAL CONCEPTSIMS GENERAL CONCEPTSFOLLOWS INVERTED TREE STRUCTUREROOT SEGMENT WILL BE ON TOPEACH SEGMENT(EXCEPT ROOT SEGMENT)IS DIRECTLY DEPENDENT ON ONLY ONE SEGMENTContinued.IMS general conceptsSegment Smallest unit of data that DL/I can fetchEach segment will have unique 8 charact
3、ers name-ARINVHDR(Invoice DB root segment)It is like a file recordIt has one or more fields like file recordGeneral concepts contd.Root segment The segment at the top of the hierarchy is root segmentDatabase Record One occurrence of root segment along with all subordinate occurrences.General Concept
4、s contd.Dependent segments All segments other than the root segment are dependent segmentsParent segment Child Segment 2413576891.WHICH SEGMENTS ARE DEPENDENT ON SEGMENT 4?2.WHICH SEGMENTS ARE CHILD SEGMENTS OF SEGMENT 1?3.WHICH SEGMENTS ARE DEPENDENT SEGMENTS OF SEGMENT 1?4.HOW MANY LEVELS?EXERCISE
5、-1EXERCISE-1IMS GENERAL CONCEPTSIMS GENERAL CONCEPTSContinued.DATABASE RECORDIMS GENERAL CONCEPTSIMS GENERAL CONCEPTSContinued.DL/I ProcessingSequential Processing Random ProcessingPosition in a DBDL/I control blocks More Into IMSDL/I and the Application ProgramDL/I Application PGM contd.DL/I acts a
6、s an interface between the application program and the access methodNo direct COBOL file I/O statements rather CALL statements to invoke DL/IDL/I invokes the access method and not the application programHow to execute IMS PGMDFSRRC00 DL/I control blocksDBD Data Base DescriptorPSB Program Specificati
7、on BlockDBDIt defines the physical structure of the databaseOne DBD for each databaseMore about DBDParent=0 for the root segment is optional and can be omittedIf two segments have the same parent their sequence in the DBDGEN job determines their sequence in the data base hierarchy Ex ARCINVCF DB.Fie
8、ld is defined as a key or search fieldSTATEMENTS IN DBD MACROSTATEMENTS IN DBD MACRODL/I CONTROL BLOCKSDL/I CONTROL BLOCKSDATA BASE DESCRIPTION(DBD)STATEMENTDESCRIPTIONDBDSPECIFIES DATABASE NAME,ACCESS METHODDATASETSPECIFIES DD NAME TO BE USED IN JCL,DISK TYPESEGMSPECIFIES SEGMENT NAME,SEGMENT LENGT
9、H,PARENTFIELDSPECIFIES FIELD NAME,LENGTH,STARTING POSITIONIDENTIFIES A FIELD AS KEY OR SEARCH FIELDContinued.SAMPLE DBDGENSAMPLE DBDGENPRINTNOGENDBDNAME=COUNTRY,ACCESS=HDAMDATASETDD1=CTRY,DEVICE=3380SEGMNAME=CTRYSEG,PARENT=0,BYTES=10FIELDNAME=(CTRCODE,SEQ,U),BYTES=10,START=1,TYPE=CSEGMNAME=STATSEG,P
10、ARENT=CTRYSEG,BYTES=5FIELDNAME=(STATCODE,SEQ,U),BYTES=5,START=1,TYPE=CSEGMNAME=DISTSEG,PARENT=STATSEG,BYTES=9FIELDNAME=(DISTCODE,SEQ),BYTES=3,START=1,TYPE=CFIELDNAME=POPULTON,BYTES=6,START=4,TYPE=PDBDGENFINISHENDDL/I CONTROL BLOCKSDL/I CONTROL BLOCKSContinued.PSBIt defines the application program vi
11、ew of the databaseSpecify the data bases(one or more)the program can accessSpecify the processing the program can do on the data elements described in the PSBApplication program can share PSBTYPEDESCRIPTIONCCharacter(Default)COBOL PICTUREXPPacked DecimalCOMP-3ZZoned DecimalS9HHalf Word Binary9(4)COM
12、PFFull Word Binary9(8)COMPDL/I CONTROL BLOCKSDL/I CONTROL BLOCKSDATATYPES USED IN DBDGENDATATYPES USED IN DBDGENContinued.ABCDEDATABASEDATABASEPCBPCBDL/I CONTROL BLOCKSDL/I CONTROL BLOCKS PCB GIVES LOGICAL VIEW OF A DATABASE PORTION OF DATABASE THAT THE PROGRAM PROCESSES IS CALLED APPLICATION DATA S
13、TRUCTUREACEContinued.PRINT NOGENPCB TYPE=DB,DBDNAME=COUNTRY,KEYLEN=15,PROCOPT=LSSENSEG NAME=CTRYSEGSENSEG NAME=STATSEG,PARENT=CTRYSEGPSBGENEND KEYLEN IS THE LENGTH OF CONCATENATED KEYDL/I CONTROL BLOCKSDL/I CONTROL BLOCKSSAMPLE PSBGENContinued.PROCOPTDESCRIPTIONGGet or ReadIInsertRReplaceDDeleteAAll
14、 Options(G,I,R,D)LInitial LoadLSSequential Initial LoadKAccess only Key of segmentOUsed with G to Indicate that Hold is not allowedPPath Calls PROCOPTS IN PSB DEFINES SECURITY LEVEL FOR THE PROGRAMDL/I CONTROL BLOCKSDL/I CONTROL BLOCKSContinued.DBD1DBD3DBD2PCB1PCB2PCB3PCB4DL/I CONTROL BLOCKSDL/I CON
15、TROL BLOCKS APPLICATION PROGRAM CAN HAVE MULTIPLE VIEWS OF A DATABASE BY USING SEPARATE PCBS FOR A SINGLE DATABASEPSBPSBContinued.PRINT NOGENPCB TYPE=DB,DBDNAME=COUNTRY,KEYLEN=15SENSEG NAME=CTRYSEG,PROCOPT=GSENSEG NAME=STATSEG,PARENT=CTRYSEG,PROCOPT=RSENSEG NAME=DISTSEG,PARENT=STATSEG,PROCOPT=APSBGE
16、NEND1.LIST THE SEGMENTS THAT MAY BE UPDATED USING THIS PSB2.LIST THE SEGMENTS THAT CANNOT BE UPDATED3.GIVE THE VALID PROCOPT TO BE CODED FOR ADDING AND REPLACING RECORDS IN CTRYSEG SEGMENTDL/I CONTROL BLOCKSDL/I CONTROL BLOCKSContinued.EMPDATAWORKDATADEPTDATABENDATABASED ON THE ABOVE VIEW OF DATABAS
17、E FILL IN THE MISSING PIECES OF PCBPCB TYPE=DB,DBDNAME=EMPDB,KEYLEN=16,PROCOPT=GSENSEG NAME=_,PARENT=_SENSEG NAME=_,PARENT=_SENSEG NAME=_,PARENT=_SENSEG NAME=_,PARENT=_PSBGEN LANG=COBOL,PSBNAME=EMPPSBYENDDL/I CONTROL BLOCKSDL/I CONTROL BLOCKSContinued.PSBSegment Level Sensitivity The program can acc
18、ess the segments defined in PCB and all fields of that segment.Field Level Sensitivity Within a segment access to specific fieldsOne program has one PSB or multiple programs can have onePCB Program Communication BlockOne PCB for each database the application program can accessIf PROCOPT coded at seg
19、ment level will overwrite the one at the segment level.Ex ARC0766 Format of Entry statementENTRY DLITCBL USING PCB-1 PCB-2 .PCB-nEntry Statement Contd.It Links all the PCBs defined in the PSBGEN to the programOrder mentioned must be same as that specified in the PSBGENThe control is transferred to t
20、he programThe address of each PCB defined in the PSB is suppliedGOBACKGOBACK is used instead of STOP RUNIt transfers control back to DL/I which then deallocates the resources and closes all DB and data setsDL/I Calls The programs use the call statement rather than direct Access method like Read,writ
21、e,Rewrite etc.The control is transferred from COBOL to DL/I which in turn does the processing CALL Statement Format CALL CBLTDLI USING FUNC-CD PCB-MASK I-O AREA SSAFunction CodeIt determines the Function to be perform on the DB.ARC includes a copybook YKDBFUNC which contains all the function which c
22、an be performed on the DB.Defined as PIC X(4)field.Function Code layout in ARC01 DB-FUNCTION-CODES.05 GU PIC X(4)VALUE GU.05 GHU PIC X(4)VALUE GHU.05 GN PIC X(4)VALUE GN.05 GHN PIC X(4)VALUE GHN.05 GNP PIC X(4)VALUE GNP.05 GHNP PIC X(4)VALUE GHNP.05 ISRT PIC X(4)VALUE ISRT.05 REPL PIC X(4)VALUE REPL
23、.05 DLET PIC X(4)VALUE DLET.Get Functions GUGNGNPGHUGHNGHNPUpdate FunctionsISRTDLETREPLPCB MaskDefined in Linkage sectionTells which DB to use for the request madeA field is used after every call to know whether the call is successful or notLINKAGELINKAGE SECTIONSECTION01DB-PCB-1.03 DBD-NAMEPIC X(8)
24、.03 SEG-LEVELPIC X(2).03 STATUS-CODEPIC X(2).03 PROC-OPTIONSPIC X(4).03 IMS-RESERVEDPIC S9(5)COMP.03 SEG-NAMEPIC X(8).03 KEY-LENPIC S9(5)COMP.03 NUM-SENS-SEGSPIC S9(5)COMP.03 KEY-FEEDBACKPIC X(?).=length depends on segment key THE PCB MASKCOBOL BASICS FOR IMSCOBOL BASICS FOR IMSContinued.There shoul
25、d be at least one PCB for each database used Status code of PCB mask explains whether a call is successful or not The sequence in which PCB masks are defined in linkage section need not be same as that in PSBGEN macro THE PCB MASKContinued.I-O AreaDefined in the working storageContains the retrieved
26、 data after the call is successfulUsed to update the segment from the contained data THE SSA IS AN AREA IN WORKING STORAGE USED TO IDENTIFY THE SEGMENT TO WHICH ACCESS IS REQUIRED IT IS AN OPTIONAL DL/I CALL PARAMETER THAT QUALIFIES A CALL BY SPECIFIYING A PARTICULAR SEGMENT TYPE OR OCCURRENCEWHEN S
27、PECIFIED IN A DL/I CALL THE SSA ALWAYS FOLLOWS I/O PARAMETER THERE MAY BE 1 TO 15 SSAs IN A CALL STATEMENT THE SSAs MUST APPEAR IN HIERARCHICAL ORDER BY SEGMENT TYPE THE SSA CONTAINS INFORMATION TO OBTAIN THE REQUIRED SEGMENT.THE INFORMATION COULD BY SEGMENT NAME OR SEGMENT NAME&SEGMENT KEY OR SEGME
28、NT NAME&SEARCH FIELDSEGMENT SEARCHSEGMENT SEARCH ARGUMENTARGUMENT UNQUALIFIED UNQUALIFIEDSEARCHES FOR A SPECIFIC SEGMENT TYPE QUALIFIED QUALIFIEDSEARCHES FOR A SPECIFIC SEGMENT OCCURRENCEMORE EFFICIENT THAN UNQUALIFIED SSATYPESTYPES OF SSASOF SSASSEGMENT SEARCH ARGUMENTSEGMENT SEARCH ARGUMENTContinu
29、ed.WORKING-STORAGE-SECTIONWORKING-STORAGE-SECTION.01 HISTORY-SSA.05 SEGMENT-NAMEPIC X(8)VALUE CTRYSEG .05 FILLERPIC X(1)VALUE SPACE.Blank in 9th position UNQUALIFIEDUNQUALIFIED SSASSAC T R Y S E GSEGMENT SEARCH ARGUMENTSEGMENT SEARCH ARGUMENTContinued.Segment Search ArgumentFirst 8 bytes contains th
30、e name of the SSA9th byte contains a blankSegment name must be the one defined in DBDGENIf segment name less than eight characters-?WORKING-STORAGE-SECTIONWORKING-STORAGE-SECTION.01 SSA-EMPLOYEE.03SEGMENT-NAMEPIC X(8)VALUE EMPLOYEE 03BEGIN-QUALIFYPIC X(1)VALUE(.03KEY-NAMEPIC X(8)VALUE EMPKEY .03OPER
31、ATORPIC X(2)VALUE =.03KEY-VALUEPIC X(12).03END-QUALIFYPIC X(1)VALUE).PROCEDURE DIVISION.MOVE 123456789000 TO KEY-VALUE.CALL CBLTDLI USING FUNC-CODE,PCB-MASK-1,IO-AREA,SSA-EMPLOYEE.QUALIFIEDQUALIFIED SSASSASEGMENT SEARCH ARGUMENTSEGMENT SEARCH ARGUMENTContinued.Segment Search Argument-QualifiedFirst
32、8 bytes contains the name of the SSA9th byte contains a(Position 10 to 17 is an eight character field name.18 and 19 2 character relational operatorEnd a field value with the)parenthesisSegment name must be the one defined in DBDGEN Segment search argument Qualified contd.Used to specify a specific
33、segment occurrence based on the field passedField can be key field or the search fieldField must be defined in the DBDGENThe key value variesOPERATORS USED IN QUALIFIED SSAOPERATORSYMBOLSEqual toEQ,=,=Not Equal toNE,=,=Less thanLT,Less than or Equal toLE,=,=,Greater than or Equal toGE,=,=SEGMENT SEA
34、RCH ARGUMENTContinued.Command CodesCOMMAND CODES INCREASE THE FUNCTIONALITY OF IMS CALLS COMMAND CODES ARE DESIGNATED BY AN ASTERISK*FOLLOWED BY CHARACTERS ONE OR MORE COMMAND CODES CAN BE USED IN SSA EACH COMMAND CODE IS REPRESENTED BY A SINGLE CHARACTER FOLLOWING AN ASTERISK AFTER SEGMENT NAMECOMM
35、AND CODESCOMMAND CODESHIS T O R Y*-DL/I CONSIDERS ALL CHARACTERS FOLLOWING*TO BE COMMAND CODES TILL IT ENCOUNTERS A BLANK OR(RESULTS IN MINIMIZING THE NUMBER OF CALLS AND HENCE IMPROVE PROGRAM EFFICIENCYCommand Codes*at the 9th byte of SSACommand code at 10th byteSpace or left parenthesis to know a
36、unqualified SSA or a qualified SSASOME COMMAND CODESSOME COMMAND CODESCOMMAND CODESCOMMAND CODESCOMMAND CODEDESCRIPTIONDRETRIEVE A PATHFFIRST OCCURRENCE OF SEGMENT TYPELLAST OCCURRENCE OF SEGMENT TYPEUMAINTAIN CURRENT POSITION AT THIS LEVELVMAINTAIN CURRENT POSITION AT THIS AND HIGHER LEVELSNDO NOT
37、REPLACE THIS SEGMENTCUSE A CONCATENATED KEYPESTABLISH PARENTAGE AT THIS LEVEL-NULL/IGNOREContinued.NULL COMMAND CODE PRESENT IN ALL SSAS IN ARC ANY SPECIFIC COMMAND CODE CAN BE USED AND MODIFY THIS FIELD TO FUNCTION ACCORDINGLYCOMMANDCOMMAND CODE“-”CODE“-”COMMAND CODESCOMMAND CODESContinued.REQUESTS
38、 DL/I TO USE PATH CALLS ALLOWS ENTIRE PATH IN SEGMENT HIERARCHY TO BE RETRIEVED IN ONE SINGLE CALL FOR PROGRAMS USING PATH CALLS PROCOPT IN PSB SHOULD HAVE“P”AS ONE OF THE VALUES DL/I DOES NOT RETRIEVE SEGMENTS IF THE CORRESPONDING SSA DOES NOT HAVE PATH COMMAND CODE“D”COMMANDCOMMAND CODE“D”CODE“D”C
39、OMMAND CODESCOMMAND CODESContinued.SEGMENT IN THE LAST SSA WILL ALWAYS BE RETRIEVED EVEN IF SSA DOES NOT HAVE COMMAND CODE“D”FOR ISRT CALLS SSAS FOR LOWER LEVEL SEGMENTS NEED NOT HAVE“D”COMMAND CODE,“D”COMMAND CODE IS PROPAGATED TO ALL SPECIFIED SEGMENTS AUTOMATICALLY I/O AREA USED SHOULD BE BIG ENO
40、UGH TO ACCOMMODATE ALL SEGMENTS IN PATHCOMMANDCOMMAND CODE“D”CODE“D”COMMAND CODESCOMMAND CODESContinued.CALL CBLTDLI USING GN ,LS-PCB-MASK,WS-SEG-IO-AREA,SEGMENTA*D(AKEY=1)SEGMENTB*D(BKEY=2)SEGMENTD*-(DKEY=5)AFTER THE CALL SEGMENTS#1,#2 WILL BE RETURNED IN I/O AREAPATH CALLS EXAMPLEPATH CALLS EXA
41、MPLE1651171042839AKEYBKEYEKEYCKEYDKEYFKEYContinued.COMMAND CODESCOMMAND CODES CALL PROCESSES FIRST OCCURRENCE OF THE SEGMENT TYPEEXAMPLE:SEGMENT 2 CAN BE RETRIEVED AFTER SEGMENT 4 BY USINGCALL CBLTDLI USING GNP LS-PCB-MASK,WS-SEG-IO-AREA,SEGMENTB*FCOMMAND CODE“F”COMMAND CODE“F”COMMAND CODESCOMMAND C
42、ODES4312SEGMENTASEGMENTBSEGMENTCContinued.COMMAND CODE“L”COMMAND CODE“L”COMMAND CODESCOMMAND CODES CALL PROCESSES LAST OCCURRENCE OF THE SEGMENT TYPEEXAMPLE:SEGMENT 4 CAN BE RETRIEVED AFTER SEGMENT 2 BY USINGCALL CBLTDLI USING GNP LS-PCB-MASK,WS-SEG-IO-AREA,SEGMENTC*L4312SEGMENTASEGMENTBSEGMENTCCont
43、inued.COMMAND CODE“N”COMMAND CODE“N”COMMAND CODESCOMMAND CODES USED IN REPL CALLS FOLLOWING PATH CALLS IF ANY SEGMENT RETRIEVED DURING PATH CALL NEED NOT BE REPLACED COMMAND CODE“N”IS USED IN SSA OF THAT SEGMENTContinued.DL/I CALLSCallsQualified Call Call with SSAUnqualified Call Call without SSAONE
44、 OF THE FOLLOWING FUNCTIONS WILL BE USED IN A RETRIEVAL DL/I CALL GU-GET UNIQUE GN-GET NEXT GNP-GET NEXT WITHIN PARENTWHEN A RETRIEVAL IS DONE WITH AN INTENT TO UPDATE OR DELETE RECORDS,THE ABOVE FUNCTION CODES WILL BE PREFIXED WITH HOLD GHU-GET HOLD UNIQUE GHN-GET HOLD NEXT GHNP-GET HOLD NEXT WITHI
45、N PARENTDL/I RETRIEVAL CALLSDL/I RETRIEVAL CALLSDL/I CALLSDL/I CALLSGU callRandom processing of recordsIndependent of the position established by previous callsCan be used with Qualified or unqualified SSAReturns 1st occurrence with unqualified Returns 1st occurrence with non-unique keyGET UNIQUEGET
46、 UNIQUECALL CBLTDLI USING GU ,PCB-MASK,SEGMENT-IO-AREASEGMENTA*-(AKEY=1)SEGMENTB*-(BKEY=2)SEGMENTD*-(DKEY=6)AFTER THE CALL SEGMENTD WITH DKEY=6 WILL BE IN SEGMENT-IO-AREA1651171042839AKEYBKEYEKEYCKEYDKEYFKEYEXERCISEEXERCISE:WRITE A GU TO RETRIEVE FKEY=10DL/I CALLSDL/I CALLSWHAT WILL BE THE OUTPUT OF
47、 A GU CALL WITH NO SSA?DL/I CALLSDL/I CALLSExpected Status codes with GUSpace if call is successfulGE Segment not foundIf GE not handled-?GETGET NEXTNEXTRETREIVALRETREIVAL SEQUENCESEQUENCE TOP TO BOTTOM FRONT TO BACK LEFT TO RIGHT1651171042839AKEYBKEYEKEYCKEYDKEYFKEYGKGADL/I CALLSDL/I CALLSContinued
48、.GN CallSequential processing of DBUsed mostly when no of segments are to read or processCan use unqualified or Qualified SSACALL CBLTDLI USING GN ,PCB-MASK,SEG-IO-AREA,SEGMENTA*-(AKEY=1)SEGMENTE*-(EKEY=8)AFTER THE CALL SEGMENTE WITH EKEY=8 WILL BE IN PROGRAM I/O AREA1651171042839AKEYBKEYEKEYCKEYDKE
49、YFKEYEXERCISEEXERCISE:WHAT WILL BE THE RESULTS OF FOUR CONSEQUETIVE GNs AFTER EKEY=8 IS RETRIEVEDDL/I CALLSDL/I CALLSCALL CBLTDLI USING GN ,LS-PCB-MASK,SEGMENT-IO-AREA,SEGMENTA*-(AKEY=1)SEGMENTB*-(BKEY=2)CALL CBLTDLI USING GNP,LS-PCB-MASK,SEGMENT-IO-AREAAFTER THE CALL SEGMENTC WITH CKEY=3 WILL BE IN
50、 SEGMENT-IO-AREAGET NEXT WITHIN PARENTGET NEXT WITHIN PARENT1651171042839AKEYBKEYEKEYCKEYDKEYFKEYDL/I CALLSDL/I CALLSWHAT WILL BE THE OUTPUT IF GNP IS DONE 4 MORE TIMES IN PREVIOUS EXAMPLE?DL/I CALLSDL/I CALLSContinued.Status Code during Sequential retrievalSpaces if the call is successfulGE Segment